Completed
Push — 1.10.x ( 3f49cd...45b387 )
by Yannick
272:36 queued 230:11
created
main/inc/lib/getid3/getid3.php 4 patches
Doc Comments   +22 added lines patch added patch discarded remove patch
@@ -456,6 +456,10 @@  discard block
 block discarded – undo
456 456
 
457 457
 
458 458
     // Add warning(s) to $this->warnings[]
459
+
460
+    /**
461
+     * @param string $message
462
+     */
459 463
     public function warning($message) {
460 464
 
461 465
         if (is_array($message)) {
@@ -482,6 +486,11 @@  discard block
 block discarded – undo
482 486
 
483 487
 
484 488
     // Convert string between charsets -- iconv() wrapper
489
+
490
+    /**
491
+     * @param string $out_charset
492
+     * @param string $string
493
+     */
485 494
     public function iconv($in_charset, $out_charset, $string, $drop01 = false) {
486 495
 
487 496
         if ($drop01 && ($string === "\x00" || $string === "\x01")) {
@@ -509,6 +518,9 @@  discard block
 block discarded – undo
509 518
 
510 519
 
511 520
 
521
+    /**
522
+     * @param string $name
523
+     */
512 524
     public function include_module($name) {
513 525
 
514 526
         if (!file_exists($this->include_path.'module.'.$name.'.php')) {
@@ -1342,6 +1354,10 @@  discard block
 block discarded – undo
1342 1354
 
1343 1355
 
1344 1356
     // Convert Big Endian byte string to int - max 32 bits
1357
+
1358
+    /**
1359
+     * @param string $byte_word
1360
+     */
1345 1361
     public static function BigEndian2Int($byte_word, $signed = false) {
1346 1362
 
1347 1363
         $int_value = 0;
@@ -1391,6 +1407,9 @@  discard block
 block discarded – undo
1391 1407
 
1392 1408
 
1393 1409
 
1410
+    /**
1411
+     * @param string $byte_word
1412
+     */
1394 1413
     public static function BigEndian2Float($byte_word) {
1395 1414
 
1396 1415
 		// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
@@ -1478,6 +1497,9 @@  discard block
 block discarded – undo
1478 1497
 
1479 1498
 
1480 1499
 
1500
+	/**
1501
+	 * @param string $binary_numerator
1502
+	 */
1481 1503
 	public static function DecimalBinary2Float($binary_numerator) {
1482 1504
 		$numerator   = bindec($binary_numerator);
1483 1505
 		$denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $class = new $class_name($this);
301 301
 
302 302
         try {
303
-             $this->option_analyze and $class->Analyze();
303
+                $this->option_analyze and $class->Analyze();
304 304
             }
305 305
         catch (getid3_exception $e) {
306 306
             throw $e;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             // CalculateReplayGain() {
384 384
             if (@$this->info['replay_gain']) {
385 385
                 if (!@$this->info['replay_gain']['reference_volume']) {
386
-                     $this->info['replay_gain']['reference_volume'] = 89;
386
+                        $this->info['replay_gain']['reference_volume'] = 89;
387 387
                 }
388 388
                 if (isset($this->info['replay_gain']['track']['adjustment'])) {
389 389
                     $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
             // ProcessAudioStreams() {
405 405
             if (@!$this->info['audio']['streams'] && (@$this->info['audio']['bitrate'] || @$this->info['audio']['channels'] || @$this->info['audio']['sample_rate'])) {
406
-                  foreach ($this->info['audio'] as $key => $value) {
406
+                    foreach ($this->info['audio'] as $key => $value) {
407 407
                     if ($key != 'streams') {
408 408
                         $this->info['audio']['streams'][0][$key] = $value;
409 409
                     }
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                             'group'     => 'audio',
545 545
                             'module'    => 'ac3',
546 546
                             'mime_type' => 'audio/ac3',
547
-                          ),
547
+                            ),
548 548
 
549 549
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADIF format
550 550
                 'adif' => array (
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                             'module'    => 'aac_adif',
554 554
                             'mime_type' => 'application/octet-stream',
555 555
                             'fail_ape'  => 'WARNING',
556
-                          ),
556
+                            ),
557 557
 
558 558
 
559 559
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                             'module'    => 'aac_adts',
564 564
                             'mime_type' => 'application/octet-stream',
565 565
                             'fail_ape'  => 'WARNING',
566
-                          ),
566
+                            ),
567 567
 
568 568
 
569 569
                 // AU   - audio       - NeXT/Sun AUdio (AU)
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
                             'group'     => 'audio',
573 573
                             'module'    => 'au',
574 574
                             'mime_type' => 'audio/basic',
575
-                          ),
575
+                            ),
576 576
 
577 577
                 // AVR  - audio       - Audio Visual Research
578 578
                 'avr'  => array (
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                             'group'     => 'audio',
581 581
                             'module'    => 'avr',
582 582
                             'mime_type' => 'application/octet-stream',
583
-                          ),
583
+                            ),
584 584
 
585 585
                 // BONK - audio       - Bonk v0.9+
586 586
                 'bonk' => array (
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
                             'group'     => 'audio',
589 589
                             'module'    => 'bonk',
590 590
                             'mime_type' => 'audio/xmms-bonk',
591
-                          ),
591
+                            ),
592 592
 
593 593
                 // DTS  - audio       - Dolby Theatre System
594
-				'dts'  => array(
595
-							'pattern'   => '^\x7F\xFE\x80\x01',
596
-							'group'     => 'audio',
597
-							'module'    => 'dts',
598
-							'mime_type' => 'audio/dts',
599
-						),
594
+                'dts'  => array(
595
+                            'pattern'   => '^\x7F\xFE\x80\x01',
596
+                            'group'     => 'audio',
597
+                            'module'    => 'dts',
598
+                            'mime_type' => 'audio/dts',
599
+                        ),
600 600
 
601 601
                 // FLAC - audio       - Free Lossless Audio Codec
602 602
                 'flac' => array (
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                             'group'     => 'audio',
605 605
                             'module'    => 'xiph',
606 606
                             'mime_type' => 'audio/x-flac',
607
-                          ),
607
+                            ),
608 608
 
609 609
                 // LA   - audio       - Lossless Audio (LA)
610 610
                 'la'   => array (
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
                             'group'     => 'audio',
613 613
                             'module'    => 'la',
614 614
                             'mime_type' => 'application/octet-stream',
615
-                          ),
615
+                            ),
616 616
 
617 617
                 // LPAC - audio       - Lossless Predictive Audio Compression (LPAC)
618 618
                 'lpac' => array (
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
                             'group'     => 'audio',
621 621
                             'module'    => 'lpac',
622 622
                             'mime_type' => 'application/octet-stream',
623
-                          ),
623
+                            ),
624 624
 
625 625
                 // MIDI - audio       - MIDI (Musical Instrument Digital Interface)
626 626
                 'midi' => array (
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                             'group'     => 'audio',
629 629
                             'module'    => 'midi',
630 630
                             'mime_type' => 'audio/midi',
631
-                          ),
631
+                            ),
632 632
 
633 633
                 // MAC  - audio       - Monkey's Audio Compressor
634 634
                 'mac'  => array (
@@ -636,31 +636,31 @@  discard block
 block discarded – undo
636 636
                             'group'     => 'audio',
637 637
                             'module'    => 'monkey',
638 638
                             'mime_type' => 'application/octet-stream',
639
-                          ),
639
+                            ),
640 640
 
641 641
                 // MOD  - audio       - MODule (assorted sub-formats)
642 642
                 'mod'  => array (
643 643
                             'pattern'   => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
644 644
                             'mime_type' => 'audio/mod',
645
-                          ),
645
+                            ),
646 646
 
647 647
                 // MOD  - audio       - MODule (Impulse Tracker)
648 648
                 'it'   => array (
649 649
                             'pattern'   => '^IMPM',
650 650
                             'mime_type' => 'audio/it',
651
-                          ),
651
+                            ),
652 652
 
653 653
                 // MOD  - audio       - MODule (eXtended Module, various sub-formats)
654 654
                 'xm'   => array (
655 655
                             'pattern'   => '^Extended Module',
656 656
                             'mime_type' => 'audio/xm',
657
-                          ),
657
+                            ),
658 658
 
659 659
                 // MOD  - audio       - MODule (ScreamTracker)
660 660
                 's3m'  => array (
661 661
                             'pattern'   => '^.{44}SCRM',
662 662
                             'mime_type' => 'audio/s3m',
663
-                          ),
663
+                            ),
664 664
 
665 665
                 // MPC  - audio       - Musepack / MPEGplus SV7+
666 666
                 'mpc'  => array (
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                             'group'     => 'audio',
669 669
                             'module'    => 'mpc',
670 670
                             'mime_type' => 'audio/x-musepack',
671
-                          ),
671
+                            ),
672 672
 
673 673
                 // MPC  - audio       - Musepack / MPEGplus SV4-6
674 674
                 'mpc_old' => array (
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                             'group'     => 'audio',
677 677
                             'module'    => 'mpc_old',
678 678
                             'mime_type' => 'application/octet-stream',
679
-                          ),
679
+                            ),
680 680
 
681 681
 
682 682
                 // MP3  - audio       - MPEG-audio Layer 3 (very similar to AAC-ADTS)
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
                             'group'     => 'audio',
686 686
                             'module'    => 'mp3',
687 687
                             'mime_type' => 'audio/mpeg',
688
-                          ),
688
+                            ),
689 689
 
690 690
                 // OFR  - audio       - OptimFROG
691 691
                 'ofr'  => array (
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
                             'group'     => 'audio',
694 694
                             'module'    => 'optimfrog',
695 695
                             'mime_type' => 'application/octet-stream',
696
-                          ),
696
+                            ),
697 697
 
698 698
                 // RKAU - audio       - RKive AUdio compressor
699 699
                 'rkau' => array (
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
                             'group'     => 'audio',
702 702
                             'module'    => 'rkau',
703 703
                             'mime_type' => 'application/octet-stream',
704
-                          ),
704
+                            ),
705 705
 
706 706
                 // SHN  - audio       - Shorten
707 707
                 'shn'  => array (
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
                             'mime_type' => 'audio/xmms-shn',
712 712
                             'fail_id3'  => 'ERROR',
713 713
                             'fail_ape'  => 'ERROR',
714
-                          ),
714
+                            ),
715 715
 
716 716
                 // TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
717 717
                 'tta'  => array (
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
                             'group'     => 'audio',
720 720
                             'module'    => 'tta',
721 721
                             'mime_type' => 'application/octet-stream',
722
-                          ),
722
+                            ),
723 723
 
724 724
                 // VOC  - audio       - Creative Voice (VOC)
725 725
                 'voc'  => array (
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                             'group'     => 'audio',
728 728
                             'module'    => 'voc',
729 729
                             'mime_type' => 'audio/voc',
730
-                          ),
730
+                            ),
731 731
 
732 732
                 // VQF  - audio       - transform-domain weighted interleave Vector Quantization Format (VQF)
733 733
                 'vqf'  => array (
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
                             'group'     => 'audio',
736 736
                             'module'    => 'vqf',
737 737
                             'mime_type' => 'application/octet-stream',
738
-                          ),
738
+                            ),
739 739
 
740 740
                 // WV  - audio        - WavPack (v4.0+)
741 741
                 'vw'  => array(
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
                             'group'     => 'audio',
744 744
                             'module'    => 'wavpack',
745 745
                             'mime_type' => 'application/octet-stream',
746
-                          ),
746
+                            ),
747 747
 
748 748
 
749 749
                 // Audio-Video formats
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
                             'group'     => 'audio-video',
755 755
                             'module'    => 'asf',
756 756
                             'mime_type' => 'video/x-ms-asf',
757
-                          ),
757
+                            ),
758 758
 
759 759
                 // BINK  - audio/video - Bink / Smacker
760 760
                 'bink' => array(
761 761
                             'pattern'   => '^(BIK|SMK)',
762 762
                             'mime_type' => 'application/octet-stream',
763
-                          ),
763
+                            ),
764 764
 
765 765
                 // FLV  - audio/video - FLash Video
766 766
                 'flv' => array(
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
                             'group'     => 'audio-video',
769 769
                             'module'    => 'flv',
770 770
                             'mime_type' => 'video/x-flv',
771
-                          ),
771
+                            ),
772 772
 
773 773
                 // MKAV - audio/video - Mastroka
774 774
                 'matroska' => array (
775 775
                             'pattern'   => '^\x1A\x45\xDF\xA3',
776 776
                             'mime_type' => 'application/octet-stream',
777
-                          ),
777
+                            ),
778 778
 
779 779
                 // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
780 780
                 'mpeg' => array (
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
                             'group'     => 'audio-video',
783 783
                             'module'    => 'mpeg',
784 784
                             'mime_type' => 'video/mpeg',
785
-                          ),
785
+                            ),
786 786
 
787 787
                 // NSV  - audio/video - Nullsoft Streaming Video (NSV)
788 788
                 'nsv'  => array (
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
                             'group'     => 'audio-video',
791 791
                             'module'    => 'nsv',
792 792
                             'mime_type' => 'application/octet-stream',
793
-                          ),
793
+                            ),
794 794
 
795 795
                 // Ogg  - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*))
796 796
                 'ogg'  => array (
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                             'mime_type' => 'application/ogg',
801 801
                             'fail_id3'  => 'WARNING',
802 802
                             'fail_ape'  => 'WARNING',
803
-                          ),
803
+                            ),
804 804
 
805 805
                 // QT   - audio/video - Quicktime
806 806
                 'quicktime' => array (
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
                             'group'     => 'audio-video',
809 809
                             'module'    => 'quicktime',
810 810
                             'mime_type' => 'video/quicktime',
811
-                          ),
811
+                            ),
812 812
 
813 813
                 // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
814 814
                 'riff' => array (
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                             'module'    => 'riff',
818 818
                             'mime_type' => 'audio/x-wave',
819 819
                             'fail_ape'  => 'WARNING',
820
-                          ),
820
+                            ),
821 821
 
822 822
                 // Real - audio/video - RealAudio, RealVideo
823 823
                 'real' => array (
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                             'group'     => 'audio-video',
826 826
                             'module'    => 'real',
827 827
                             'mime_type' => 'audio/x-realaudio',
828
-                          ),
828
+                            ),
829 829
 
830 830
                 // SWF - audio/video - ShockWave Flash
831 831
                 'swf' => array (
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                             'group'     => 'audio-video',
834 834
                             'module'    => 'swf',
835 835
                             'mime_type' => 'application/x-shockwave-flash',
836
-                          ),
836
+                            ),
837 837
 
838 838
 
839 839
                 // Still-Image formats
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
                             'mime_type' => 'image/bmp',
847 847
                             'fail_id3'  => 'ERROR',
848 848
                             'fail_ape'  => 'ERROR',
849
-                          ),
849
+                            ),
850 850
 
851 851
                 // GIF  - still image - Graphics Interchange Format
852 852
                 'gif'  => array (
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
                             'mime_type' => 'image/gif',
857 857
                             'fail_id3'  => 'ERROR',
858 858
                             'fail_ape'  => 'ERROR',
859
-                          ),
859
+                            ),
860 860
 
861 861
                 // JPEG - still image - Joint Photographic Experts Group (JPEG)
862 862
                 'jpeg'  => array (
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
                             'mime_type' => 'image/jpeg',
867 867
                             'fail_id3'  => 'ERROR',
868 868
                             'fail_ape'  => 'ERROR',
869
-                          ),
869
+                            ),
870 870
 
871 871
                 // PCD  - still image - Kodak Photo CD
872 872
                 'pcd'  => array (
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                             'mime_type' => 'image/x-photo-cd',
877 877
                             'fail_id3'  => 'ERROR',
878 878
                             'fail_ape'  => 'ERROR',
879
-                          ),
879
+                            ),
880 880
 
881 881
 
882 882
                 // PNG  - still image - Portable Network Graphics (PNG)
@@ -887,16 +887,16 @@  discard block
 block discarded – undo
887 887
                             'mime_type' => 'image/png',
888 888
                             'fail_id3'  => 'ERROR',
889 889
                             'fail_ape'  => 'ERROR',
890
-                          ),
890
+                            ),
891 891
 
892 892
 
893 893
                 // SVG  - still image - Scalable Vector Graphics (SVG)
894
-				'svg'  => array(
895
-							'pattern'   => '<!DOCTYPE svg PUBLIC ',
896
-							'mime_type' => 'image/svg+xml',
897
-							'fail_id3'  => 'ERROR',
898
-							'fail_ape'  => 'ERROR',
899
-						),
894
+                'svg'  => array(
895
+                            'pattern'   => '<!DOCTYPE svg PUBLIC ',
896
+                            'mime_type' => 'image/svg+xml',
897
+                            'fail_id3'  => 'ERROR',
898
+                            'fail_ape'  => 'ERROR',
899
+                        ),
900 900
 
901 901
 
902 902
                 // TIFF  - still image - Tagged Information File Format (TIFF)
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
                             'mime_type' => 'image/tiff',
908 908
                             'fail_id3'  => 'ERROR',
909 909
                             'fail_ape'  => 'ERROR',
910
-                          ),
910
+                            ),
911 911
 
912 912
 
913 913
                 // Data formats
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
                             'mime_type' => 'application/octet-stream',
918 918
                             'fail_id3'  => 'ERROR',
919 919
                             'fail_ape'  => 'ERROR',
920
-                          ),
920
+                            ),
921 921
 
922 922
                 // ISO  - data        - International Standards Organization (ISO) CD-ROM Image
923 923
                 'iso'  => array (
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
                             'mime_type' => 'application/octet-stream',
928 928
                             'fail_id3'  => 'ERROR',
929 929
                             'fail_ape'  => 'ERROR',
930
-                          ),
930
+                            ),
931 931
 
932 932
                 // RAR  - data        - RAR compressed data
933 933
                 'rar'  => array(
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
                             'mime_type' => 'application/octet-stream',
936 936
                             'fail_id3'  => 'ERROR',
937 937
                             'fail_ape'  => 'ERROR',
938
-                          ),
938
+                            ),
939 939
 
940 940
                 // SZIP - audio       - SZIP compressed data
941 941
                 'szip' => array (
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
                             'mime_type' => 'application/octet-stream',
946 946
                             'fail_id3'  => 'ERROR',
947 947
                             'fail_ape'  => 'ERROR',
948
-                          ),
948
+                            ),
949 949
 
950 950
                 // TAR  - data        - TAR compressed data
951 951
                 'tar'  => array(
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
                             'mime_type' => 'application/x-tar',
956 956
                             'fail_id3'  => 'ERROR',
957 957
                             'fail_ape'  => 'ERROR',
958
-                          ),
958
+                            ),
959 959
 
960 960
                 // GZIP  - data        - GZIP compressed data
961 961
                 'gz'  => array(
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
                             'mime_type' => 'application/x-gzip',
966 966
                             'fail_id3'  => 'ERROR',
967 967
                             'fail_ape'  => 'ERROR',
968
-                          ),
968
+                            ),
969 969
 
970 970
 
971 971
                 // ZIP  - data        - ZIP compressed data
@@ -976,33 +976,33 @@  discard block
 block discarded – undo
976 976
                             'mime_type' => 'application/zip',
977 977
                             'fail_id3'  => 'ERROR',
978 978
                             'fail_ape'  => 'ERROR',
979
-                          ),
979
+                            ),
980 980
 
981 981
 
982 982
                 // PAR2 - data        - Parity Volume Set Specification 2.0
983 983
                 'par2' => array (
984
-                			'pattern'   => '^PAR2\x00PKT',
985
-							'mime_type' => 'application/octet-stream',
986
-							'fail_id3'  => 'ERROR',
987
-							'fail_ape'  => 'ERROR',
988
-						),
984
+                            'pattern'   => '^PAR2\x00PKT',
985
+                            'mime_type' => 'application/octet-stream',
986
+                            'fail_id3'  => 'ERROR',
987
+                            'fail_ape'  => 'ERROR',
988
+                        ),
989 989
 
990 990
 
991
-                 // PDF  - data       - Portable Document Format
992
-                 'pdf' => array(
991
+                    // PDF  - data       - Portable Document Format
992
+                    'pdf' => array(
993 993
                             'pattern'   => '^\x25PDF',
994 994
                             'mime_type' => 'application/pdf',
995 995
                             'fail_id3'  => 'ERROR',
996 996
                             'fail_ape'  => 'ERROR',
997
-                           ),
997
+                            ),
998 998
 
999
-                 // DOC  - data       - Microsoft Word
1000
-                 'msoffice' => array(
999
+                    // DOC  - data       - Microsoft Word
1000
+                    'msoffice' => array(
1001 1001
                             'pattern'   => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
1002 1002
                             'mime_type' => 'application/octet-stream',
1003 1003
                             'fail_id3'  => 'ERROR',
1004 1004
                             'fail_ape'  => 'ERROR',
1005
-                          ),
1005
+                            ),
1006 1006
             );
1007 1007
 
1008 1008
         return $format_info;
@@ -1393,99 +1393,99 @@  discard block
 block discarded – undo
1393 1393
 
1394 1394
     public static function BigEndian2Float($byte_word) {
1395 1395
 
1396
-		// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
1397
-		// http://www.psc.edu/general/software/packages/ieee/ieee.html
1398
-		// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
1396
+        // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
1397
+        // http://www.psc.edu/general/software/packages/ieee/ieee.html
1398
+        // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
1399 1399
 
1400
-		$bit_word = getid3_lib::BigEndian2Bin($byte_word);
1401
-		if (!$bit_word) {
1400
+        $bit_word = getid3_lib::BigEndian2Bin($byte_word);
1401
+        if (!$bit_word) {
1402 1402
             return 0;
1403 1403
         }
1404
-		$sign_bit = $bit_word{0};
1405
-
1406
-		switch (strlen($byte_word) * 8) {
1407
-			case 32:
1408
-				$exponent_bits = 8;
1409
-				$fraction_bits = 23;
1410
-				break;
1411
-
1412
-			case 64:
1413
-				$exponent_bits = 11;
1414
-				$fraction_bits = 52;
1415
-				break;
1416
-
1417
-			case 80:
1418
-				// 80-bit Apple SANE format
1419
-				// http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
1420
-				$exponent_string = substr($bit_word, 1, 15);
1421
-				$is_normalized = intval($bit_word{16});
1422
-				$fraction_string = substr($bit_word, 17, 63);
1423
-				$exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383);
1424
-				$fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string);
1425
-				$float_value = $exponent * $fraction;
1426
-				if ($sign_bit == '1') {
1427
-					$float_value *= -1;
1428
-				}
1429
-				return $float_value;
1430
-				break;
1431
-
1432
-			default:
1433
-				return false;
1434
-				break;
1435
-		}
1436
-		$exponent_string = substr($bit_word, 1, $exponent_bits);
1437
-		$fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
1438
-		$exponent = bindec($exponent_string);
1439
-		$fraction = bindec($fraction_string);
1440
-
1441
-		if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) {
1442
-			// Not a Number
1443
-			$float_value = false;
1444
-		} elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) {
1445
-			if ($sign_bit == '1') {
1446
-				$float_value = '-infinity';
1447
-			} else {
1448
-				$float_value = '+infinity';
1449
-			}
1450
-		} elseif (($exponent == 0) && ($fraction == 0)) {
1451
-			if ($sign_bit == '1') {
1452
-				$float_value = -0;
1453
-			} else {
1454
-				$float_value = 0;
1455
-			}
1456
-			$float_value = ($sign_bit ? 0 : -0);
1457
-		} elseif (($exponent == 0) && ($fraction != 0)) {
1458
-			// These are 'unnormalized' values
1459
-			$float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string);
1460
-			if ($sign_bit == '1') {
1461
-				$float_value *= -1;
1462
-			}
1463
-		} elseif ($exponent != 0) {
1464
-			$float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string));
1465
-			if ($sign_bit == '1') {
1466
-				$float_value *= -1;
1467
-			}
1468
-		}
1469
-		return (float) $float_value;
1470
-	}
1471
-
1472
-
1473
-
1474
-	public static function LittleEndian2Float($byte_word) {
1475
-
1476
-		return getid3_lib::BigEndian2Float(strrev($byte_word));
1477
-	}
1478
-
1479
-
1480
-
1481
-	public static function DecimalBinary2Float($binary_numerator) {
1482
-		$numerator   = bindec($binary_numerator);
1483
-		$denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
1484
-		return ($numerator / $denominator);
1485
-	}
1486
-
1487
-
1488
-	public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) {
1404
+        $sign_bit = $bit_word{0};
1405
+
1406
+        switch (strlen($byte_word) * 8) {
1407
+            case 32:
1408
+                $exponent_bits = 8;
1409
+                $fraction_bits = 23;
1410
+                break;
1411
+
1412
+            case 64:
1413
+                $exponent_bits = 11;
1414
+                $fraction_bits = 52;
1415
+                break;
1416
+
1417
+            case 80:
1418
+                // 80-bit Apple SANE format
1419
+                // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
1420
+                $exponent_string = substr($bit_word, 1, 15);
1421
+                $is_normalized = intval($bit_word{16});
1422
+                $fraction_string = substr($bit_word, 17, 63);
1423
+                $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383);
1424
+                $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string);
1425
+                $float_value = $exponent * $fraction;
1426
+                if ($sign_bit == '1') {
1427
+                    $float_value *= -1;
1428
+                }
1429
+                return $float_value;
1430
+                break;
1431
+
1432
+            default:
1433
+                return false;
1434
+                break;
1435
+        }
1436
+        $exponent_string = substr($bit_word, 1, $exponent_bits);
1437
+        $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
1438
+        $exponent = bindec($exponent_string);
1439
+        $fraction = bindec($fraction_string);
1440
+
1441
+        if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) {
1442
+            // Not a Number
1443
+            $float_value = false;
1444
+        } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) {
1445
+            if ($sign_bit == '1') {
1446
+                $float_value = '-infinity';
1447
+            } else {
1448
+                $float_value = '+infinity';
1449
+            }
1450
+        } elseif (($exponent == 0) && ($fraction == 0)) {
1451
+            if ($sign_bit == '1') {
1452
+                $float_value = -0;
1453
+            } else {
1454
+                $float_value = 0;
1455
+            }
1456
+            $float_value = ($sign_bit ? 0 : -0);
1457
+        } elseif (($exponent == 0) && ($fraction != 0)) {
1458
+            // These are 'unnormalized' values
1459
+            $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string);
1460
+            if ($sign_bit == '1') {
1461
+                $float_value *= -1;
1462
+            }
1463
+        } elseif ($exponent != 0) {
1464
+            $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string));
1465
+            if ($sign_bit == '1') {
1466
+                $float_value *= -1;
1467
+            }
1468
+        }
1469
+        return (float) $float_value;
1470
+    }
1471
+
1472
+
1473
+
1474
+    public static function LittleEndian2Float($byte_word) {
1475
+
1476
+        return getid3_lib::BigEndian2Float(strrev($byte_word));
1477
+    }
1478
+
1479
+
1480
+
1481
+    public static function DecimalBinary2Float($binary_numerator) {
1482
+        $numerator   = bindec($binary_numerator);
1483
+        $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
1484
+        return ($numerator / $denominator);
1485
+    }
1486
+
1487
+
1488
+    public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) {
1489 1489
 
1490 1490
         $return_string = '';
1491 1491
         for ($i = 0; $i < strlen($string); $i++) {
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
     //// Settings Section - do NOT modify this file - change setting after newing getid3!
28 28
 
29 29
     // Encoding
30
-    public $encoding                 = 'ISO-8859-1';      // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/).  Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE.
31
-    public $encoding_id3v1           = 'ISO-8859-1';      // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic".
32
-    public $encoding_id3v2           = 'ISO-8859-1';      // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8.
30
+    public $encoding                 = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/).  Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE.
31
+    public $encoding_id3v1           = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic".
32
+    public $encoding_id3v2           = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8.
33 33
 
34 34
     // Tags - disable for speed
35
-    public $option_tag_id3v1         = false;              // Read and process ID3v1 tags.
36
-    public $option_tag_id3v2         = false;              // Read and process ID3v2 tags.
37
-    public $option_tag_lyrics3       = false;              // Read and process Lyrics3 tags.
38
-    public $option_tag_apetag        = false;              // Read and process APE tags.
35
+    public $option_tag_id3v1         = false; // Read and process ID3v1 tags.
36
+    public $option_tag_id3v2         = false; // Read and process ID3v2 tags.
37
+    public $option_tag_lyrics3       = false; // Read and process Lyrics3 tags.
38
+    public $option_tag_apetag        = false; // Read and process APE tags.
39 39
 
40 40
     // Misc calucations - disable for speed
41
-    public $option_analyze           = true;              // Analyze file - disable if you only need to detect file format.
42
-    public $option_accurate_results  = true;              // Disable to greatly speed up parsing of some file formats at the cost of accuracy.
43
-    public $option_tags_process      = true;              // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding.
44
-    public $option_tags_images       = false;             // Scan tags for binary image data - ID3v2 and vorbiscomments only.
45
-    public $option_extra_info        = true;              // Calculate/return additional info such as bitrate, channelmode etc.
46
-    public $option_max_2gb_check     = false;             // Check whether file is larger than 2 Gb and thus not supported by PHP.
41
+    public $option_analyze           = true; // Analyze file - disable if you only need to detect file format.
42
+    public $option_accurate_results  = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy.
43
+    public $option_tags_process      = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding.
44
+    public $option_tags_images       = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only.
45
+    public $option_extra_info        = true; // Calculate/return additional info such as bitrate, channelmode etc.
46
+    public $option_max_2gb_check     = false; // Check whether file is larger than 2 Gb and thus not supported by PHP.
47 47
 
48 48
     // Misc data hashes - slow - require hash module
49
-    public $option_md5_data          = false;             // Get MD5 sum of data part - slow.
50
-    public $option_md5_data_source   = false;             // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4.
51
-    public $option_sha1_data         = false;             // Get SHA1 sum of data part - slow.
49
+    public $option_md5_data          = false; // Get MD5 sum of data part - slow.
50
+    public $option_md5_data_source   = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4.
51
+    public $option_sha1_data         = false; // Get SHA1 sum of data part - slow.
52 52
 
53 53
     // Public variables
54
-    public $filename;                                     // Filename of file being analysed.
55
-    public $fp;                                           // Filepointer to file being analysed.
56
-    public $info;                                         // Result array.
54
+    public $filename; // Filename of file being analysed.
55
+    public $fp; // Filepointer to file being analysed.
56
+    public $info; // Result array.
57 57
 
58 58
     // Protected variables
59
-    protected $include_path;                              // getid3 include path.
60
-    protected $warnings = array ();
59
+    protected $include_path; // getid3 include path.
60
+    protected $warnings = array();
61 61
     protected $iconv_present;
62 62
 
63 63
     // Class constants
64 64
     const VERSION           = '2.0.0b4';
65
-    const FREAD_BUFFER_SIZE = 16384;                      // Read buffer size in bytes.
65
+    const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes.
66 66
     const ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~�������������������������������� �����������������������������������������������������������������������������������������������';
67 67
 
68 68
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 
89 89
         // Get include_path
90
-        $this->include_path = $include_path = dirname(__FILE__) . '/';
90
+        $this->include_path = $include_path = dirname(__FILE__).'/';
91 91
 
92 92
         // Check for presence of iconv() and make sure it works (simpel test only).
93 93
         if (function_exists('iconv') && @iconv('UTF-16LE', 'ISO-8859-1', @iconv('ISO-8859-1', 'UTF-16LE', getid3::ICONV_TEST_STRING)) == getid3::ICONV_TEST_STRING) {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 
125 125
         // Check safe_mode off
126
-        if ((bool)ini_get('safe_mode')) {
126
+        if ((bool) ini_get('safe_mode')) {
127 127
             $this->warning('Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbis/flac tag writing disabled.');
128 128
         }
129 129
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
         // Init and save values
139 139
         $this->filename = $filename;
140
-        $this->warnings = array ();
140
+        $this->warnings = array();
141 141
 
142 142
         // Init result array and set parameters
143
-        $this->info = array ();
143
+        $this->info = array();
144 144
         $this->info['GETID3_VERSION'] = getid3::VERSION;
145 145
 
146 146
         // Remote files not supported
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
             fseek($this->fp, 0, SEEK_SET);
181 181
             $header = fread($this->fp, 10);
182
-            if (substr($header, 0, 3) == 'ID3'  &&  strlen($header) == 10) {
182
+            if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
183 183
                 $this->info['id3v2']['header']        = true;
184 184
                 $this->info['id3v2']['majorversion']  = ord($header{3});
185 185
                 $this->info['id3v2']['minorversion']  = ord($header{4});
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 
190 190
 
191 191
         // Handle tags
192
-        foreach (array ("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) {
192
+        foreach (array("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) {
193 193
 
194
-            $option_tag = 'option_tag_' . $tag_name;
194
+            $option_tag = 'option_tag_'.$tag_name;
195 195
             if ($this->$option_tag) {
196 196
                 $this->include_module('tag.'.$tag_name);
197 197
                 try {
198
-                    $tag_class = 'getid3_' . $tag_name;
198
+                    $tag_class = 'getid3_'.$tag_name;
199 199
                     $tag = new $tag_class($this);
200 200
                     $tag->Analyze();
201 201
                 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                     return $this->info;
232 232
                 }
233 233
 
234
-                $determined_format = $info;  // copy $info deleted by foreach()
234
+                $determined_format = $info; // copy $info deleted by foreach()
235 235
                 continue;
236 236
             }
237 237
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
             // Set playtime string
343 343
             if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
344
-                $this->info['playtime_string'] =  floor(round($this->info['playtime_seconds']) / 60) . ':' . str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT);;
344
+                $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60).':'.str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT); ;
345 345
             }
346 346
 
347 347
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             if (@$this->info['video'] && @$this->info['video']['resolution_x'] && @$this->info['video']['resolution_y'] && @$this->info['video']['bits_per_sample']) {
350 350
 
351 351
                 // From static image formats
352
-                if (in_array($this->info['video']['dataformat'], array ('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) {
352
+                if (in_array($this->info['video']['dataformat'], array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) {
353 353
                     $frame_rate         = 1;
354 354
                     $bitrate_compressed = $this->info['filesize'] * 8;
355 355
                 }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
     //  Clear all warnings when cloning
472 472
     public function __clone() {
473 473
 
474
-        $this->warnings = array ();
474
+        $this->warnings = array();
475 475
 
476 476
         // Copy info array, otherwise it will be a reference.
477 477
         $temp = $this->info;
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
             return $result;
504 504
         }
505 505
 
506
-        $this->warning('iconv() was unable to convert the string: "' . $string . '" from ' . $in_charset . ' to ' . $out_charset);
506
+        $this->warning('iconv() was unable to convert the string: "'.$string.'" from '.$in_charset.' to '.$out_charset);
507 507
         return $string;
508 508
     }
509 509
 
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
     // Return array containing information about all supported formats
535 535
     public static function GetFileFormatArray() {
536 536
 
537
-        static $format_info = array (
537
+        static $format_info = array(
538 538
 
539 539
                 // Audio formats
540 540
 
541 541
                 // AC-3   - audio      - Dolby AC-3 / Dolby Digital
542
-                'ac3'  => array (
542
+                'ac3'  => array(
543 543
                             'pattern'   => '^\x0B\x77',
544 544
                             'group'     => 'audio',
545 545
                             'module'    => 'ac3',
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                           ),
548 548
 
549 549
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADIF format
550
-                'adif' => array (
550
+                'adif' => array(
551 551
                             'pattern'   => '^ADIF',
552 552
                             'group'     => 'audio',
553 553
                             'module'    => 'aac_adif',
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 
559 559
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
560
-                'adts' => array (
560
+                'adts' => array(
561 561
                             'pattern'   => '^\xFF[\xF0-\xF1\xF8-\xF9]',
562 562
                             'group'     => 'audio',
563 563
                             'module'    => 'aac_adts',
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 
569 569
                 // AU   - audio       - NeXT/Sun AUdio (AU)
570
-                'au'   => array (
570
+                'au'   => array(
571 571
                             'pattern'   => '^\.snd',
572 572
                             'group'     => 'audio',
573 573
                             'module'    => 'au',
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                           ),
576 576
 
577 577
                 // AVR  - audio       - Audio Visual Research
578
-                'avr'  => array (
578
+                'avr'  => array(
579 579
                             'pattern'   => '^2BIT',
580 580
                             'group'     => 'audio',
581 581
                             'module'    => 'avr',
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                           ),
584 584
 
585 585
                 // BONK - audio       - Bonk v0.9+
586
-                'bonk' => array (
586
+                'bonk' => array(
587 587
                             'pattern'   => '^\x00(BONK|INFO|META| ID3)',
588 588
                             'group'     => 'audio',
589 589
                             'module'    => 'bonk',
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 						),
600 600
 
601 601
                 // FLAC - audio       - Free Lossless Audio Codec
602
-                'flac' => array (
602
+                'flac' => array(
603 603
                             'pattern'   => '^fLaC',
604 604
                             'group'     => 'audio',
605 605
                             'module'    => 'xiph',
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                           ),
608 608
 
609 609
                 // LA   - audio       - Lossless Audio (LA)
610
-                'la'   => array (
610
+                'la'   => array(
611 611
                             'pattern'   => '^LA0[2-4]',
612 612
                             'group'     => 'audio',
613 613
                             'module'    => 'la',
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
                           ),
616 616
 
617 617
                 // LPAC - audio       - Lossless Predictive Audio Compression (LPAC)
618
-                'lpac' => array (
618
+                'lpac' => array(
619 619
                             'pattern'   => '^LPAC',
620 620
                             'group'     => 'audio',
621 621
                             'module'    => 'lpac',
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                           ),
624 624
 
625 625
                 // MIDI - audio       - MIDI (Musical Instrument Digital Interface)
626
-                'midi' => array (
626
+                'midi' => array(
627 627
                             'pattern'   => '^MThd',
628 628
                             'group'     => 'audio',
629 629
                             'module'    => 'midi',
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                           ),
632 632
 
633 633
                 // MAC  - audio       - Monkey's Audio Compressor
634
-                'mac'  => array (
634
+                'mac'  => array(
635 635
                             'pattern'   => '^MAC ',
636 636
                             'group'     => 'audio',
637 637
                             'module'    => 'monkey',
@@ -639,31 +639,31 @@  discard block
 block discarded – undo
639 639
                           ),
640 640
 
641 641
                 // MOD  - audio       - MODule (assorted sub-formats)
642
-                'mod'  => array (
642
+                'mod'  => array(
643 643
                             'pattern'   => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
644 644
                             'mime_type' => 'audio/mod',
645 645
                           ),
646 646
 
647 647
                 // MOD  - audio       - MODule (Impulse Tracker)
648
-                'it'   => array (
648
+                'it'   => array(
649 649
                             'pattern'   => '^IMPM',
650 650
                             'mime_type' => 'audio/it',
651 651
                           ),
652 652
 
653 653
                 // MOD  - audio       - MODule (eXtended Module, various sub-formats)
654
-                'xm'   => array (
654
+                'xm'   => array(
655 655
                             'pattern'   => '^Extended Module',
656 656
                             'mime_type' => 'audio/xm',
657 657
                           ),
658 658
 
659 659
                 // MOD  - audio       - MODule (ScreamTracker)
660
-                's3m'  => array (
660
+                's3m'  => array(
661 661
                             'pattern'   => '^.{44}SCRM',
662 662
                             'mime_type' => 'audio/s3m',
663 663
                           ),
664 664
 
665 665
                 // MPC  - audio       - Musepack / MPEGplus SV7+
666
-                'mpc'  => array (
666
+                'mpc'  => array(
667 667
                             'pattern'   => '^(MP\+)',
668 668
                             'group'     => 'audio',
669 669
                             'module'    => 'mpc',
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                           ),
672 672
 
673 673
                 // MPC  - audio       - Musepack / MPEGplus SV4-6
674
-                'mpc_old' => array (
674
+                'mpc_old' => array(
675 675
                             'pattern'   => '^([\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
676 676
                             'group'     => 'audio',
677 677
                             'module'    => 'mpc_old',
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 
681 681
 
682 682
                 // MP3  - audio       - MPEG-audio Layer 3 (very similar to AAC-ADTS)
683
-                'mp3'  => array (
683
+                'mp3'  => array(
684 684
                             'pattern'   => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
685 685
                             'group'     => 'audio',
686 686
                             'module'    => 'mp3',
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                           ),
689 689
 
690 690
                 // OFR  - audio       - OptimFROG
691
-                'ofr'  => array (
691
+                'ofr'  => array(
692 692
                             'pattern'   => '^(\*RIFF|OFR)',
693 693
                             'group'     => 'audio',
694 694
                             'module'    => 'optimfrog',
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
                           ),
697 697
 
698 698
                 // RKAU - audio       - RKive AUdio compressor
699
-                'rkau' => array (
699
+                'rkau' => array(
700 700
                             'pattern'   => '^RKA',
701 701
                             'group'     => 'audio',
702 702
                             'module'    => 'rkau',
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
                           ),
705 705
 
706 706
                 // SHN  - audio       - Shorten
707
-                'shn'  => array (
707
+                'shn'  => array(
708 708
                             'pattern'   => '^ajkg',
709 709
                             'group'     => 'audio',
710 710
                             'module'    => 'shorten',
@@ -714,15 +714,15 @@  discard block
 block discarded – undo
714 714
                           ),
715 715
 
716 716
                 // TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
717
-                'tta'  => array (
718
-                            'pattern'   => '^TTA',  // could also be '^TTA(\x01|\x02|\x03|2|1)'
717
+                'tta'  => array(
718
+                            'pattern'   => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
719 719
                             'group'     => 'audio',
720 720
                             'module'    => 'tta',
721 721
                             'mime_type' => 'application/octet-stream',
722 722
                           ),
723 723
 
724 724
                 // VOC  - audio       - Creative Voice (VOC)
725
-                'voc'  => array (
725
+                'voc'  => array(
726 726
                             'pattern'   => '^Creative Voice File',
727 727
                             'group'     => 'audio',
728 728
                             'module'    => 'voc',
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
                           ),
731 731
 
732 732
                 // VQF  - audio       - transform-domain weighted interleave Vector Quantization Format (VQF)
733
-                'vqf'  => array (
733
+                'vqf'  => array(
734 734
                             'pattern'   => '^TWIN',
735 735
                             'group'     => 'audio',
736 736
                             'module'    => 'vqf',
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
                 // Audio-Video formats
750 750
 
751 751
                 // ASF  - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
752
-                'asf'  => array (
752
+                'asf'  => array(
753 753
                             'pattern'   => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
754 754
                             'group'     => 'audio-video',
755 755
                             'module'    => 'asf',
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
                           ),
772 772
 
773 773
                 // MKAV - audio/video - Mastroka
774
-                'matroska' => array (
774
+                'matroska' => array(
775 775
                             'pattern'   => '^\x1A\x45\xDF\xA3',
776 776
                             'mime_type' => 'application/octet-stream',
777 777
                           ),
778 778
 
779 779
                 // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
780
-                'mpeg' => array (
780
+                'mpeg' => array(
781 781
                             'pattern'   => '^\x00\x00\x01(\xBA|\xB3)',
782 782
                             'group'     => 'audio-video',
783 783
                             'module'    => 'mpeg',
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
                           ),
786 786
 
787 787
                 // NSV  - audio/video - Nullsoft Streaming Video (NSV)
788
-                'nsv'  => array (
788
+                'nsv'  => array(
789 789
                             'pattern'   => '^NSV[sf]',
790 790
                             'group'     => 'audio-video',
791 791
                             'module'    => 'nsv',
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
                           ),
794 794
 
795 795
                 // Ogg  - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*))
796
-                'ogg'  => array (
796
+                'ogg'  => array(
797 797
                             'pattern'   => '^OggS',
798 798
                             'group'     => 'audio',
799 799
                             'module'    => 'xiph',
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                           ),
804 804
 
805 805
                 // QT   - audio/video - Quicktime
806
-                'quicktime' => array (
806
+                'quicktime' => array(
807 807
                             'pattern'   => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
808 808
                             'group'     => 'audio-video',
809 809
                             'module'    => 'quicktime',
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
                           ),
812 812
 
813 813
                 // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
814
-                'riff' => array (
814
+                'riff' => array(
815 815
                             'pattern'   => '^(RIFF|SDSS|FORM)',
816 816
                             'group'     => 'audio-video',
817 817
                             'module'    => 'riff',
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                           ),
821 821
 
822 822
                 // Real - audio/video - RealAudio, RealVideo
823
-                'real' => array (
823
+                'real' => array(
824 824
                             'pattern'   => '^(\.RMF|.ra)',
825 825
                             'group'     => 'audio-video',
826 826
                             'module'    => 'real',
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
                           ),
829 829
 
830 830
                 // SWF - audio/video - ShockWave Flash
831
-                'swf' => array (
831
+                'swf' => array(
832 832
                             'pattern'   => '^(F|C)WS',
833 833
                             'group'     => 'audio-video',
834 834
                             'module'    => 'swf',
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
                 // Still-Image formats
840 840
 
841 841
                 // BMP  - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
842
-                'bmp'  => array (
842
+                'bmp'  => array(
843 843
                             'pattern'   => '^BM',
844 844
                             'group'     => 'graphic',
845 845
                             'module'    => 'bmp',
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
                           ),
850 850
 
851 851
                 // GIF  - still image - Graphics Interchange Format
852
-                'gif'  => array (
852
+                'gif'  => array(
853 853
                             'pattern'   => '^GIF',
854 854
                             'group'     => 'graphic',
855 855
                             'module'    => 'gif',
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                           ),
860 860
 
861 861
                 // JPEG - still image - Joint Photographic Experts Group (JPEG)
862
-                'jpeg'  => array (
862
+                'jpeg'  => array(
863 863
                             'pattern'   => '^\xFF\xD8\xFF',
864 864
                             'group'     => 'graphic',
865 865
                             'module'    => 'jpeg',
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                           ),
870 870
 
871 871
                 // PCD  - still image - Kodak Photo CD
872
-                'pcd'  => array (
872
+                'pcd'  => array(
873 873
                             'pattern'   => '^.{2048}PCD_IPI\x00',
874 874
                             'group'     => 'graphic',
875 875
                             'module'    => 'pcd',
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
                 // PNG  - still image - Portable Network Graphics (PNG)
883
-                'png'  => array (
883
+                'png'  => array(
884 884
                             'pattern'   => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
885 885
                             'group'     => 'graphic',
886 886
                             'module'    => 'png',
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 
901 901
 
902 902
                 // TIFF  - still image - Tagged Information File Format (TIFF)
903
-                'tiff' => array (
903
+                'tiff' => array(
904 904
                             'pattern'   => '^(II\x2A\x00|MM\x00\x2A)',
905 905
                             'group'     => 'graphic',
906 906
                             'module'    => 'tiff',
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
                           ),
921 921
 
922 922
                 // ISO  - data        - International Standards Organization (ISO) CD-ROM Image
923
-                'iso'  => array (
923
+                'iso'  => array(
924 924
                             'pattern'   => '^.{32769}CD001',
925 925
                             'group'     => 'misc',
926 926
                             'module'    => 'iso',
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
                           ),
939 939
 
940 940
                 // SZIP - audio       - SZIP compressed data
941
-                'szip' => array (
941
+                'szip' => array(
942 942
                             'pattern'   => '^SZ\x0A\x04',
943 943
                             'group'     => 'archive',
944 944
                             'module'    => 'szip',
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 
970 970
 
971 971
                 // ZIP  - data        - ZIP compressed data
972
-                'zip'  => array (
972
+                'zip'  => array(
973 973
                             'pattern'   => '^PK\x03\x04',
974 974
                             'group'     => 'archive',
975 975
                             'module'    => 'zip',
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 
981 981
 
982 982
                 // PAR2 - data        - Parity Volume Set Specification 2.0
983
-                'par2' => array (
983
+                'par2' => array(
984 984
                 			'pattern'   => '^PAR2\x00PKT',
985 985
 							'mime_type' => 'application/octet-stream',
986 986
 							'fail_id3'  => 'ERROR',
@@ -1039,22 +1039,22 @@  discard block
 block discarded – undo
1039 1039
     protected function HandleAllTags() {
1040 1040
 
1041 1041
         // Key name => array (tag name, character encoding)
1042
-        static $tags = array (
1043
-            'asf'       => array ('asf',           'UTF-16LE'),
1044
-            'midi'      => array ('midi',          'ISO-8859-1'),
1045
-            'nsv'       => array ('nsv',           'ISO-8859-1'),
1046
-            'ogg'       => array ('vorbiscomment', 'UTF-8'),
1047
-            'png'       => array ('png',           'UTF-8'),
1048
-            'tiff'      => array ('tiff',          'ISO-8859-1'),
1049
-            'quicktime' => array ('quicktime',     'ISO-8859-1'),
1050
-            'real'      => array ('real',          'ISO-8859-1'),
1051
-            'vqf'       => array ('vqf',           'ISO-8859-1'),
1052
-            'zip'       => array ('zip',           'ISO-8859-1'),
1053
-            'riff'      => array ('riff',          'ISO-8859-1'),
1054
-            'lyrics3'   => array ('lyrics3',       'ISO-8859-1'),
1055
-            'id3v1'     => array ('id3v1',         ''),            // change below - cannot assign variable to static array
1056
-            'id3v2'     => array ('id3v2',         'UTF-8'),       // module converts all frames to UTF-8
1057
-            'ape'       => array ('ape',           'UTF-8')
1042
+        static $tags = array(
1043
+            'asf'       => array('asf', 'UTF-16LE'),
1044
+            'midi'      => array('midi', 'ISO-8859-1'),
1045
+            'nsv'       => array('nsv', 'ISO-8859-1'),
1046
+            'ogg'       => array('vorbiscomment', 'UTF-8'),
1047
+            'png'       => array('png', 'UTF-8'),
1048
+            'tiff'      => array('tiff', 'ISO-8859-1'),
1049
+            'quicktime' => array('quicktime', 'ISO-8859-1'),
1050
+            'real'      => array('real', 'ISO-8859-1'),
1051
+            'vqf'       => array('vqf', 'ISO-8859-1'),
1052
+            'zip'       => array('zip', 'ISO-8859-1'),
1053
+            'riff'      => array('riff', 'ISO-8859-1'),
1054
+            'lyrics3'   => array('lyrics3', 'ISO-8859-1'),
1055
+            'id3v1'     => array('id3v1', ''), // change below - cannot assign variable to static array
1056
+            'id3v2'     => array('id3v2', 'UTF-8'), // module converts all frames to UTF-8
1057
+            'ape'       => array('ape', 'UTF-8')
1058 1058
         );
1059 1059
         $tags['id3v1'][1] = $this->encoding_id3v1;
1060 1060
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
             list($tag_name, $encoding) = $tag_name_encoding_array;
1064 1064
 
1065 1065
             // Fill in default encoding type if not already present
1066
-            @$this->info[$comment_name]  and  $this->info[$comment_name]['encoding'] = $encoding;
1066
+            @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding;
1067 1067
 
1068 1068
             // Copy comments if key name set
1069 1069
             if (@$this->info[$comment_name]['comments']) {
@@ -1142,11 +1142,11 @@  discard block
 block discarded – undo
1142 1142
 abstract class getid3_handler
1143 1143
 {
1144 1144
 
1145
-    protected $getid3;                          // pointer
1145
+    protected $getid3; // pointer
1146 1146
 
1147
-    protected $data_string_flag = false;        // analyzing filepointer or string
1148
-    protected $data_string;                     // string to analyze
1149
-    protected $data_string_position = 0;        // seek position in string
1147
+    protected $data_string_flag = false; // analyzing filepointer or string
1148
+    protected $data_string; // string to analyze
1149
+    protected $data_string_position = 0; // seek position in string
1150 1150
 
1151 1151
 
1152 1152
     public function __construct(getID3 $getid3) {
@@ -1247,20 +1247,20 @@  discard block
 block discarded – undo
1247 1247
     public function __construct($filename) {
1248 1248
 
1249 1249
         if (!file_exists($filename)) {
1250
-            throw new getid3_exception('File does not exist: "' . $filename . '"');
1250
+            throw new getid3_exception('File does not exist: "'.$filename.'"');
1251 1251
         }
1252 1252
 
1253 1253
         if (!is_writeable($filename)) {
1254
-            throw new getid3_exception('File is not writeable: "' . $filename . '"');
1254
+            throw new getid3_exception('File is not writeable: "'.$filename.'"');
1255 1255
         }
1256 1256
 
1257 1257
         if (!is_writeable(dirname($filename))) {
1258
-            throw new getid3_exception('Directory is not writeable: ' . dirname($filename) . ' (need to write lock file).');
1258
+            throw new getid3_exception('Directory is not writeable: '.dirname($filename).' (need to write lock file).');
1259 1259
         }
1260 1260
 
1261 1261
         $this->user_abort = ignore_user_abort(true);
1262 1262
 
1263
-        $this->fp_lock = fopen($filename . '.getid3.lock', 'w');
1263
+        $this->fp_lock = fopen($filename.'.getid3.lock', 'w');
1264 1264
         flock($this->fp_lock, LOCK_EX);
1265 1265
 
1266 1266
         $this->filename = $filename;
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 
1272 1272
         flock($this->fp_lock, LOCK_UN);
1273 1273
         fclose($this->fp_lock);
1274
-        unlink($this->filename . '.getid3.lock');
1274
+        unlink($this->filename.'.getid3.lock');
1275 1275
 
1276 1276
         ignore_user_abort($this->user_abort);
1277 1277
     }
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 
1327 1327
     // Convert number to Little Endian byte string
1328
-    public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
1328
+    public static function LittleEndian2String($number, $minbytes = 1, $synchsafe = false) {
1329 1329
         $intstring = '';
1330 1330
         while ($number > 0) {
1331 1331
             if ($synchsafe) {
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 	}
1486 1486
 
1487 1487
 
1488
-	public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) {
1488
+	public static function PrintHexBytes($string, $hex = true, $spaces = true, $html_safe = true) {
1489 1489
 
1490 1490
         $return_string = '';
1491 1491
         for ($i = 0; $i < strlen($string); $i++) {
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 
1546 1546
     public static function NameLookup($name_code) {
1547 1547
 
1548
-        static $lookup = array (
1548
+        static $lookup = array(
1549 1549
             0 => 'not set',
1550 1550
             1 => 'Track Gain Adjustment',
1551 1551
             2 => 'Album Gain Adjustment'
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 
1559 1559
     public static function OriginatorLookup($originator_code) {
1560 1560
 
1561
-        static $lookup = array (
1561
+        static $lookup = array(
1562 1562
             0 => 'unspecified',
1563 1563
             1 => 'pre-set by artist/producer/mastering engineer',
1564 1564
             2 => 'set by user',
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 
1573 1573
     public static function AdjustmentLookup($raw_adjustment, $sign_bit) {
1574 1574
 
1575
-        return (float)$raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1);
1575
+        return (float) $raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1);
1576 1576
     }
1577 1577
 
1578 1578
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -17 removed lines patch added patch discarded remove patch
@@ -198,8 +198,7 @@  discard block
 block discarded – undo
198 198
                     $tag_class = 'getid3_' . $tag_name;
199 199
                     $tag = new $tag_class($this);
200 200
                     $tag->Analyze();
201
-                }
202
-                catch (getid3_exception $e) {
201
+                } catch (getid3_exception $e) {
203 202
                     throw $e;
204 203
                 }
205 204
             }
@@ -243,9 +242,7 @@  discard block
 block discarded – undo
243 242
             // use assume format on these if format detection failed
244 243
             if (preg_match('/\.mp[123a]$/i', $filename)) {
245 244
                 $determined_format = $file_format_array['mp3'];
246
-            }
247
-
248
-            else {
245
+            } else {
249 246
                 fclose($this->fp);
250 247
                 throw new getid3_exception('Unable to determine file format');
251 248
             }
@@ -259,8 +256,7 @@  discard block
 block discarded – undo
259 256
             if ($determined_format['fail_id3'] === 'ERROR') {
260 257
                 fclose($this->fp);
261 258
                 throw new getid3_exception('ID3 tags not allowed on this file type.');
262
-            }
263
-            elseif ($determined_format['fail_id3'] === 'WARNING') {
259
+            } elseif ($determined_format['fail_id3'] === 'WARNING') {
264 260
                 @$this->info['id3v1'] and $this->warning('ID3v1 tags not allowed on this file type.');
265 261
                 @$this->info['id3v2'] and $this->warning('ID3v2 tags not allowed on this file type.');
266 262
             }
@@ -301,11 +297,9 @@  discard block
 block discarded – undo
301 297
 
302 298
         try {
303 299
              $this->option_analyze and $class->Analyze();
304
-            }
305
-        catch (getid3_exception $e) {
300
+            } catch (getid3_exception $e) {
306 301
             throw $e;
307
-        }
308
-        catch (Exception $e) {
302
+        } catch (Exception $e) {
309 303
             throw new getid3_exception('Corrupt file.');
310 304
         }
311 305
 
@@ -460,8 +454,7 @@  discard block
 block discarded – undo
460 454
 
461 455
         if (is_array($message)) {
462 456
             $this->warnings = array_merge($this->warnings, $message);
463
-        }
464
-        else {
457
+        } else {
465 458
             $this->warnings[] = $message;
466 459
         }
467 460
     }
@@ -1101,8 +1094,7 @@  discard block
 block discarded – undo
1101 1094
                             if (empty($this->info['comments'][$tag_name])) {
1102 1095
 
1103 1096
                                 // fall through and append value
1104
-                            }
1105
-                            elseif ($tag_type == 'id3v1') {
1097
+                            } elseif ($tag_type == 'id3v1') {
1106 1098
 
1107 1099
                                 $new_value_length = strlen(trim($value));
1108 1100
                                 foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) {
@@ -1112,8 +1104,7 @@  discard block
 block discarded – undo
1112 1104
                                         break 2;
1113 1105
                                     }
1114 1106
                                 }
1115
-                            }
1116
-                            else {
1107
+                            } else {
1117 1108
 
1118 1109
                                 $new_value_length = strlen(trim($value));
1119 1110
                                 foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) {
Please login to merge, or discard this patch.
main/inc/lib/getid3/module.audio-video.flv.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -276,6 +276,9 @@  discard block
 block discarded – undo
276 276
 	public $pos;
277 277
 
278 278
 
279
+	/**
280
+	 * @param string $bytes
281
+	 */
279 282
 	public function AMFStream($bytes) {
280 283
 
281 284
 		$this->bytes = $bytes;
@@ -389,6 +392,9 @@  discard block
 block discarded – undo
389 392
 {
390 393
 	public $stream;
391 394
 
395
+	/**
396
+	 * @param AMFStream $stream
397
+	 */
392 398
 	public function __construct($stream) {
393 399
 
394 400
 		$this->stream = $stream;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class getid3_flv extends getid3_handler {
49 49
 
50
-    const TAG_AUDIO    =  8;
51
-    const TAG_VIDEO    =  9;
50
+    const TAG_AUDIO    = 8;
51
+    const TAG_VIDEO    = 9;
52 52
     const TAG_META     = 18;
53 53
 
54 54
     const VIDEO_H263   = 2;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 	    $info = &$this->getid3->info;
62 62
 
63
-	    $info['flv'] = array ();
63
+	    $info['flv'] = array();
64 64
 	    $info_flv = &$info['flv'];
65 65
 
66 66
 		fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$flv_header = fread($this->getid3->fp, 5);
70 70
 
71 71
 		$info['fileformat'] = 'flv';
72
-		$info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
72
+		$info_flv['header']['signature'] = substr($flv_header, 0, 3);
73 73
 		$info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74 74
 		$type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75 75
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 
88 88
 			$this_tag_header = fread($this->getid3->fp, 16);
89 89
 
90
-			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
-			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
-			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
-			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
90
+			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4));
91
+			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1));
92
+			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3));
93
+			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3));
94 94
 			$last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95 95
 			$next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96 96
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 				case getid3_flv::TAG_AUDIO:
100 100
 					if (!isset($info_flv['audio']['audioFormat'])) {
101
-						$info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
101
+						$info_flv['audio']['audioFormat']     = $last_header_byte & 0x07;
102 102
 						$info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103 103
 						$info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104 104
 						$info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 
402 402
 		$type = $this->stream->readByte();
403 403
 
404
-		switch($type) {
404
+		switch ($type) {
405 405
 			// Double
406 406
 			case 0:
407 407
 				$value = $this->readDouble();
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -56,522 +56,522 @@
 block discarded – undo
56 56
     const VIDEO_VP6    = 4;
57 57
 
58 58
 
59
-	public function Analyze()
60
-	{
61
-	    $info = &$this->getid3->info;
62
-
63
-	    $info['flv'] = array ();
64
-	    $info_flv = &$info['flv'];
65
-
66
-		fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
67
-
68
-		$flv_data_length = $info['avdataend'] - $info['avdataoffset'];
69
-		$flv_header = fread($this->getid3->fp, 5);
70
-
71
-		$info['fileformat'] = 'flv';
72
-		$info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
73
-		$info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74
-		$type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75
-
76
-		$info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04);
77
-		$info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01);
78
-
79
-		$frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
80
-		$flv_header_frame_length = 9;
81
-		if ($frame_size_data_length > $flv_header_frame_length) {
82
-			fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
83
-		}
84
-
85
-		$duration = 0;
86
-		while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) {
87
-
88
-			$this_tag_header = fread($this->getid3->fp, 16);
89
-
90
-			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
-			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
-			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
-			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
94
-			$last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95
-			$next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96
-
97
-			switch ($tag_type) {
98
-
99
-				case getid3_flv::TAG_AUDIO:
100
-					if (!isset($info_flv['audio']['audioFormat'])) {
101
-						$info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
102
-						$info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103
-						$info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104
-						$info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
105
-					}
106
-					break;
107
-
108
-
109
-				case getid3_flv::TAG_VIDEO:
110
-					if (!isset($info_flv['video']['videoCodec'])) {
111
-						$info_flv['video']['videoCodec'] = $last_header_byte & 0x07;
112
-
113
-						$flv_video_header = fread($this->getid3->fp, 11);
114
-
115
-						if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) {
116
-
117
-							$picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7;
118
-							$picture_size_type = $picture_size_type & 0x0007;
119
-							$info_flv['header']['videoSizeType'] = $picture_size_type;
120
-
121
-							switch ($picture_size_type) {
122
-								case 0:
123
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2));
124
-									$picture_size_enc <<= 1;
125
-									$info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8;
126
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2));
127
-									$picture_size_enc <<= 1;
128
-									$info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8;
129
-									break;
130
-
131
-								case 1:
132
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4));
133
-									$picture_size_enc <<= 1;
134
-									$info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16;
135
-
136
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4));
137
-									$picture_size_enc <<= 1;
138
-									$info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16;
139
-									break;
140
-
141
-								case 2:
142
-									$info['video']['resolution_x'] = 352;
143
-									$info['video']['resolution_y'] = 288;
144
-									break;
145
-
146
-								case 3:
147
-									$info['video']['resolution_x'] = 176;
148
-									$info['video']['resolution_y'] = 144;
149
-									break;
150
-
151
-								case 4:
152
-									$info['video']['resolution_x'] = 128;
153
-									$info['video']['resolution_y'] = 96;
154
-									break;
155
-
156
-								case 5:
157
-									$info['video']['resolution_x'] = 320;
158
-									$info['video']['resolution_y'] = 240;
159
-									break;
160
-
161
-								case 6:
162
-									$info['video']['resolution_x'] = 160;
163
-									$info['video']['resolution_y'] = 120;
164
-									break;
165
-
166
-								default:
167
-									$info['video']['resolution_x'] = 0;
168
-									$info['video']['resolution_y'] = 0;
169
-									break;
170
-							}
171
-						}
172
-					}
173
-					break;
174
-
175
-
176
-				// Meta tag
177
-				case getid3_flv::TAG_META:
178
-
179
-					fseek($this->getid3->fp, -1, SEEK_CUR);
180
-					$reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length)));
181
-					$event_name = $reader->readData();
182
-					$info['meta'][$event_name] = $reader->readData();
183
-					unset($reader);
184
-
185
-					$info['video']['frame_rate']   = @$info['meta']['onMetaData']['framerate'];
186
-					$info['video']['resolution_x'] = @$info['meta']['onMetaData']['width'];
187
-					$info['video']['resolution_y'] = @$info['meta']['onMetaData']['height'];
188
-					break;
189
-
190
-				default:
191
-					// noop
192
-					break;
193
-			}
194
-
195
-			if ($timestamp > $duration) {
196
-				$duration = $timestamp;
197
-			}
198
-
199
-			fseek($this->getid3->fp, $next_offset, SEEK_SET);
200
-		}
201
-
202
-		if ($info['playtime_seconds'] = $duration / 1000) {
203
-		    $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'];
204
-		}
205
-
206
-		if ($info_flv['header']['hasAudio']) {
207
-			$info['audio']['codec']           = $this->FLVaudioFormat($info_flv['audio']['audioFormat']);
208
-			$info['audio']['sample_rate']     = $this->FLVaudioRate($info_flv['audio']['audioRate']);
209
-			$info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']);
210
-
211
-			$info['audio']['channels']   = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo
212
-			$info['audio']['lossless']   = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed
213
-			$info['audio']['dataformat'] = 'flv';
214
-		}
215
-		if (@$info_flv['header']['hasVideo']) {
216
-			$info['video']['codec']      = $this->FLVvideoCodec($info_flv['video']['videoCodec']);
217
-			$info['video']['dataformat'] = 'flv';
218
-			$info['video']['lossless']   = false;
219
-		}
220
-
221
-		return true;
222
-	}
223
-
224
-
225
-	public static function FLVaudioFormat($id) {
226
-
227
-		static $lookup = array(
228
-			0 => 'uncompressed',
229
-			1 => 'ADPCM',
230
-			2 => 'mp3',
231
-			5 => 'Nellymoser 8kHz mono',
232
-			6 => 'Nellymoser',
233
-		);
234
-		return (@$lookup[$id] ? @$lookup[$id] : false);
235
-	}
236
-
237
-
238
-	public static function FLVaudioRate($id) {
239
-
240
-		static $lookup = array(
241
-			0 =>  5500,
242
-			1 => 11025,
243
-			2 => 22050,
244
-			3 => 44100,
245
-		);
246
-		return (@$lookup[$id] ? @$lookup[$id] : false);
247
-	}
248
-
249
-
250
-	public static function FLVaudioBitDepth($id) {
251
-
252
-		static $lookup = array(
253
-			0 =>  8,
254
-			1 => 16,
255
-		);
256
-		return (@$lookup[$id] ? @$lookup[$id] : false);
257
-	}
258
-
259
-
260
-	public static function FLVvideoCodec($id) {
261
-
262
-		static $lookup = array(
263
-			getid3_flv::VIDEO_H263   => 'Sorenson H.263',
264
-			getid3_flv::VIDEO_SCREEN => 'Screen video',
265
-			getid3_flv::VIDEO_VP6    => 'On2 VP6',
266
-		);
267
-		return (@$lookup[$id] ? @$lookup[$id] : false);
268
-	}
59
+    public function Analyze()
60
+    {
61
+        $info = &$this->getid3->info;
62
+
63
+        $info['flv'] = array ();
64
+        $info_flv = &$info['flv'];
65
+
66
+        fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
67
+
68
+        $flv_data_length = $info['avdataend'] - $info['avdataoffset'];
69
+        $flv_header = fread($this->getid3->fp, 5);
70
+
71
+        $info['fileformat'] = 'flv';
72
+        $info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
73
+        $info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74
+        $type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75
+
76
+        $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04);
77
+        $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01);
78
+
79
+        $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
80
+        $flv_header_frame_length = 9;
81
+        if ($frame_size_data_length > $flv_header_frame_length) {
82
+            fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
83
+        }
84
+
85
+        $duration = 0;
86
+        while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) {
87
+
88
+            $this_tag_header = fread($this->getid3->fp, 16);
89
+
90
+            $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
+            $tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
+            $data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
+            $timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
94
+            $last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95
+            $next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96
+
97
+            switch ($tag_type) {
98
+
99
+                case getid3_flv::TAG_AUDIO:
100
+                    if (!isset($info_flv['audio']['audioFormat'])) {
101
+                        $info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
102
+                        $info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103
+                        $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104
+                        $info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
105
+                    }
106
+                    break;
107
+
108
+
109
+                case getid3_flv::TAG_VIDEO:
110
+                    if (!isset($info_flv['video']['videoCodec'])) {
111
+                        $info_flv['video']['videoCodec'] = $last_header_byte & 0x07;
112
+
113
+                        $flv_video_header = fread($this->getid3->fp, 11);
114
+
115
+                        if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) {
116
+
117
+                            $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7;
118
+                            $picture_size_type = $picture_size_type & 0x0007;
119
+                            $info_flv['header']['videoSizeType'] = $picture_size_type;
120
+
121
+                            switch ($picture_size_type) {
122
+                                case 0:
123
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2));
124
+                                    $picture_size_enc <<= 1;
125
+                                    $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8;
126
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2));
127
+                                    $picture_size_enc <<= 1;
128
+                                    $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8;
129
+                                    break;
130
+
131
+                                case 1:
132
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4));
133
+                                    $picture_size_enc <<= 1;
134
+                                    $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16;
135
+
136
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4));
137
+                                    $picture_size_enc <<= 1;
138
+                                    $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16;
139
+                                    break;
140
+
141
+                                case 2:
142
+                                    $info['video']['resolution_x'] = 352;
143
+                                    $info['video']['resolution_y'] = 288;
144
+                                    break;
145
+
146
+                                case 3:
147
+                                    $info['video']['resolution_x'] = 176;
148
+                                    $info['video']['resolution_y'] = 144;
149
+                                    break;
150
+
151
+                                case 4:
152
+                                    $info['video']['resolution_x'] = 128;
153
+                                    $info['video']['resolution_y'] = 96;
154
+                                    break;
155
+
156
+                                case 5:
157
+                                    $info['video']['resolution_x'] = 320;
158
+                                    $info['video']['resolution_y'] = 240;
159
+                                    break;
160
+
161
+                                case 6:
162
+                                    $info['video']['resolution_x'] = 160;
163
+                                    $info['video']['resolution_y'] = 120;
164
+                                    break;
165
+
166
+                                default:
167
+                                    $info['video']['resolution_x'] = 0;
168
+                                    $info['video']['resolution_y'] = 0;
169
+                                    break;
170
+                            }
171
+                        }
172
+                    }
173
+                    break;
174
+
175
+
176
+                // Meta tag
177
+                case getid3_flv::TAG_META:
178
+
179
+                    fseek($this->getid3->fp, -1, SEEK_CUR);
180
+                    $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length)));
181
+                    $event_name = $reader->readData();
182
+                    $info['meta'][$event_name] = $reader->readData();
183
+                    unset($reader);
184
+
185
+                    $info['video']['frame_rate']   = @$info['meta']['onMetaData']['framerate'];
186
+                    $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width'];
187
+                    $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height'];
188
+                    break;
189
+
190
+                default:
191
+                    // noop
192
+                    break;
193
+            }
194
+
195
+            if ($timestamp > $duration) {
196
+                $duration = $timestamp;
197
+            }
198
+
199
+            fseek($this->getid3->fp, $next_offset, SEEK_SET);
200
+        }
201
+
202
+        if ($info['playtime_seconds'] = $duration / 1000) {
203
+            $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'];
204
+        }
205
+
206
+        if ($info_flv['header']['hasAudio']) {
207
+            $info['audio']['codec']           = $this->FLVaudioFormat($info_flv['audio']['audioFormat']);
208
+            $info['audio']['sample_rate']     = $this->FLVaudioRate($info_flv['audio']['audioRate']);
209
+            $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']);
210
+
211
+            $info['audio']['channels']   = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo
212
+            $info['audio']['lossless']   = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed
213
+            $info['audio']['dataformat'] = 'flv';
214
+        }
215
+        if (@$info_flv['header']['hasVideo']) {
216
+            $info['video']['codec']      = $this->FLVvideoCodec($info_flv['video']['videoCodec']);
217
+            $info['video']['dataformat'] = 'flv';
218
+            $info['video']['lossless']   = false;
219
+        }
220
+
221
+        return true;
222
+    }
223
+
224
+
225
+    public static function FLVaudioFormat($id) {
226
+
227
+        static $lookup = array(
228
+            0 => 'uncompressed',
229
+            1 => 'ADPCM',
230
+            2 => 'mp3',
231
+            5 => 'Nellymoser 8kHz mono',
232
+            6 => 'Nellymoser',
233
+        );
234
+        return (@$lookup[$id] ? @$lookup[$id] : false);
235
+    }
236
+
237
+
238
+    public static function FLVaudioRate($id) {
239
+
240
+        static $lookup = array(
241
+            0 =>  5500,
242
+            1 => 11025,
243
+            2 => 22050,
244
+            3 => 44100,
245
+        );
246
+        return (@$lookup[$id] ? @$lookup[$id] : false);
247
+    }
248
+
249
+
250
+    public static function FLVaudioBitDepth($id) {
251
+
252
+        static $lookup = array(
253
+            0 =>  8,
254
+            1 => 16,
255
+        );
256
+        return (@$lookup[$id] ? @$lookup[$id] : false);
257
+    }
258
+
259
+
260
+    public static function FLVvideoCodec($id) {
261
+
262
+        static $lookup = array(
263
+            getid3_flv::VIDEO_H263   => 'Sorenson H.263',
264
+            getid3_flv::VIDEO_SCREEN => 'Screen video',
265
+            getid3_flv::VIDEO_VP6    => 'On2 VP6',
266
+        );
267
+        return (@$lookup[$id] ? @$lookup[$id] : false);
268
+    }
269 269
 }
270 270
 
271 271
 
272 272
 
273 273
 class AMFStream
274 274
 {
275
-	public $bytes;
276
-	public $pos;
275
+    public $bytes;
276
+    public $pos;
277 277
 
278 278
 
279
-	public function AMFStream($bytes) {
279
+    public function AMFStream($bytes) {
280 280
 
281
-		$this->bytes = $bytes;
282
-		$this->pos = 0;
283
-	}
281
+        $this->bytes = $bytes;
282
+        $this->pos = 0;
283
+    }
284 284
 
285 285
 
286
-	public function readByte() {
286
+    public function readByte() {
287 287
 
288
-		return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
289
-	}
288
+        return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
289
+    }
290 290
 
291 291
 
292
-	public function readInt() {
292
+    public function readInt() {
293 293
 
294
-		return ($this->readByte() << 8) + $this->readByte();
295
-	}
294
+        return ($this->readByte() << 8) + $this->readByte();
295
+    }
296 296
 
297 297
 
298
-	public function readLong() {
298
+    public function readLong() {
299 299
 
300
-		return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
301
-	}
300
+        return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
301
+    }
302 302
 
303 303
 
304
-	public function readDouble() {
304
+    public function readDouble() {
305 305
 
306
-		return getid3_lib::BigEndian2Float($this->read(8));
307
-	}
306
+        return getid3_lib::BigEndian2Float($this->read(8));
307
+    }
308 308
 
309 309
 
310
-	public function readUTF() {
310
+    public function readUTF() {
311 311
 
312
-		$length = $this->readInt();
313
-		return $this->read($length);
314
-	}
312
+        $length = $this->readInt();
313
+        return $this->read($length);
314
+    }
315 315
 
316 316
 
317
-	public function readLongUTF() {
317
+    public function readLongUTF() {
318 318
 
319
-		$length = $this->readLong();
320
-		return $this->read($length);
321
-	}
319
+        $length = $this->readLong();
320
+        return $this->read($length);
321
+    }
322 322
 
323 323
 
324
-	public function read($length) {
324
+    public function read($length) {
325 325
 
326
-		$val = substr($this->bytes, $this->pos, $length);
327
-		$this->pos += $length;
328
-		return $val;
329
-	}
326
+        $val = substr($this->bytes, $this->pos, $length);
327
+        $this->pos += $length;
328
+        return $val;
329
+    }
330 330
 
331 331
 
332
-	public function peekByte() {
332
+    public function peekByte() {
333 333
 
334
-		$pos = $this->pos;
335
-		$val = $this->readByte();
336
-		$this->pos = $pos;
337
-		return $val;
338
-	}
334
+        $pos = $this->pos;
335
+        $val = $this->readByte();
336
+        $this->pos = $pos;
337
+        return $val;
338
+    }
339 339
 
340 340
 
341
-	public function peekInt() {
341
+    public function peekInt() {
342 342
 
343
-		$pos = $this->pos;
344
-		$val = $this->readInt();
345
-		$this->pos = $pos;
346
-		return $val;
347
-	}
343
+        $pos = $this->pos;
344
+        $val = $this->readInt();
345
+        $this->pos = $pos;
346
+        return $val;
347
+    }
348 348
 
349 349
 
350
-	public function peekLong() {
350
+    public function peekLong() {
351 351
 
352
-		$pos = $this->pos;
353
-		$val = $this->readLong();
354
-		$this->pos = $pos;
355
-		return $val;
356
-	}
352
+        $pos = $this->pos;
353
+        $val = $this->readLong();
354
+        $this->pos = $pos;
355
+        return $val;
356
+    }
357 357
 
358 358
 
359
-	public function peekDouble() {
359
+    public function peekDouble() {
360 360
 
361
-		$pos = $this->pos;
362
-		$val = $this->readDouble();
363
-		$this->pos = $pos;
364
-		return $val;
365
-	}
361
+        $pos = $this->pos;
362
+        $val = $this->readDouble();
363
+        $this->pos = $pos;
364
+        return $val;
365
+    }
366 366
 
367 367
 
368
-	public function peekUTF() {
368
+    public function peekUTF() {
369 369
 
370
-		$pos = $this->pos;
371
-		$val = $this->readUTF();
372
-		$this->pos = $pos;
373
-		return $val;
374
-	}
370
+        $pos = $this->pos;
371
+        $val = $this->readUTF();
372
+        $this->pos = $pos;
373
+        return $val;
374
+    }
375 375
 
376 376
 
377
-	public function peekLongUTF() {
377
+    public function peekLongUTF() {
378 378
 
379
-		$pos = $this->pos;
380
-		$val = $this->readLongUTF();
381
-		$this->pos = $pos;
382
-		return $val;
383
-	}
379
+        $pos = $this->pos;
380
+        $val = $this->readLongUTF();
381
+        $this->pos = $pos;
382
+        return $val;
383
+    }
384 384
 }
385 385
 
386 386
 
387 387
 
388 388
 class AMFReader
389 389
 {
390
-	public $stream;
390
+    public $stream;
391 391
 
392
-	public function __construct($stream) {
392
+    public function __construct($stream) {
393 393
 
394
-		$this->stream = $stream;
395
-	}
394
+        $this->stream = $stream;
395
+    }
396 396
 
397 397
 
398
-	public function readData() {
398
+    public function readData() {
399 399
 
400
-		$value = null;
400
+        $value = null;
401 401
 
402
-		$type = $this->stream->readByte();
402
+        $type = $this->stream->readByte();
403 403
 
404
-		switch($type) {
405
-			// Double
406
-			case 0:
407
-				$value = $this->readDouble();
408
-			break;
404
+        switch($type) {
405
+            // Double
406
+            case 0:
407
+                $value = $this->readDouble();
408
+            break;
409 409
 
410
-			// Boolean
411
-			case 1:
412
-				$value = $this->readBoolean();
413
-				break;
410
+            // Boolean
411
+            case 1:
412
+                $value = $this->readBoolean();
413
+                break;
414 414
 
415
-			// String
416
-			case 2:
417
-				$value = $this->readString();
418
-				break;
415
+            // String
416
+            case 2:
417
+                $value = $this->readString();
418
+                break;
419 419
 
420
-			// Object
421
-			case 3:
422
-				$value = $this->readObject();
423
-				break;
420
+            // Object
421
+            case 3:
422
+                $value = $this->readObject();
423
+                break;
424 424
 
425
-			// null
426
-			case 6:
427
-				return null;
428
-				break;
425
+            // null
426
+            case 6:
427
+                return null;
428
+                break;
429 429
 
430
-			// Mixed array
431
-			case 8:
432
-				$value = $this->readMixedArray();
433
-				break;
430
+            // Mixed array
431
+            case 8:
432
+                $value = $this->readMixedArray();
433
+                break;
434 434
 
435
-			// Array
436
-			case 10:
437
-				$value = $this->readArray();
438
-				break;
435
+            // Array
436
+            case 10:
437
+                $value = $this->readArray();
438
+                break;
439 439
 
440
-			// Date
441
-			case 11:
442
-				$value = $this->readDate();
443
-				break;
440
+            // Date
441
+            case 11:
442
+                $value = $this->readDate();
443
+                break;
444 444
 
445
-			// Long string
446
-			case 13:
447
-				$value = $this->readLongString();
448
-				break;
445
+            // Long string
446
+            case 13:
447
+                $value = $this->readLongString();
448
+                break;
449 449
 
450
-			// XML (handled as string)
451
-			case 15:
452
-				$value = $this->readXML();
453
-				break;
450
+            // XML (handled as string)
451
+            case 15:
452
+                $value = $this->readXML();
453
+                break;
454 454
 
455
-			// Typed object (handled as object)
456
-			case 16:
457
-				$value = $this->readTypedObject();
458
-				break;
455
+            // Typed object (handled as object)
456
+            case 16:
457
+                $value = $this->readTypedObject();
458
+                break;
459 459
 
460
-			// Long string
461
-			default:
462
-				$value = '(unknown or unsupported data type)';
463
-			break;
464
-		}
460
+            // Long string
461
+            default:
462
+                $value = '(unknown or unsupported data type)';
463
+            break;
464
+        }
465 465
 
466
-		return $value;
467
-	}
466
+        return $value;
467
+    }
468 468
 
469 469
 
470
-	public function readDouble() {
470
+    public function readDouble() {
471 471
 
472
-		return $this->stream->readDouble();
473
-	}
472
+        return $this->stream->readDouble();
473
+    }
474 474
 
475 475
 
476
-	public function readBoolean() {
476
+    public function readBoolean() {
477 477
 
478
-		return $this->stream->readByte() == 1;
479
-	}
478
+        return $this->stream->readByte() == 1;
479
+    }
480 480
 
481 481
 
482
-	public function readString() {
482
+    public function readString() {
483 483
 
484
-		return $this->stream->readUTF();
485
-	}
484
+        return $this->stream->readUTF();
485
+    }
486 486
 
487 487
 
488
-	public function readObject() {
488
+    public function readObject() {
489 489
 
490
-		// Get highest numerical index - ignored
491
-		$highestIndex = $this->stream->readLong();
490
+        // Get highest numerical index - ignored
491
+        $highestIndex = $this->stream->readLong();
492 492
 
493
-		$data = array();
493
+        $data = array();
494 494
 
495
-		while ($key = $this->stream->readUTF()) {
496
-			// Mixed array record ends with empty string (0x00 0x00) and 0x09
497
-			if (($key == '') && ($this->stream->peekByte() == 0x09)) {
498
-				// Consume byte
499
-				$this->stream->readByte();
500
-				break;
501
-			}
495
+        while ($key = $this->stream->readUTF()) {
496
+            // Mixed array record ends with empty string (0x00 0x00) and 0x09
497
+            if (($key == '') && ($this->stream->peekByte() == 0x09)) {
498
+                // Consume byte
499
+                $this->stream->readByte();
500
+                break;
501
+            }
502 502
 
503
-			$data[$key] = $this->readData();
504
-		}
503
+            $data[$key] = $this->readData();
504
+        }
505 505
 
506
-		return $data;
507
-	}
506
+        return $data;
507
+    }
508 508
 
509 509
 
510
-	public function readMixedArray() {
510
+    public function readMixedArray() {
511 511
 
512
-		// Get highest numerical index - ignored
513
-		$highestIndex = $this->stream->readLong();
512
+        // Get highest numerical index - ignored
513
+        $highestIndex = $this->stream->readLong();
514 514
 
515
-		$data = array();
515
+        $data = array();
516 516
 
517
-		while ($key = $this->stream->readUTF()) {
518
-			// Mixed array record ends with empty string (0x00 0x00) and 0x09
519
-			if (($key == '') && ($this->stream->peekByte() == 0x09)) {
520
-				// Consume byte
521
-				$this->stream->readByte();
522
-				break;
523
-			}
517
+        while ($key = $this->stream->readUTF()) {
518
+            // Mixed array record ends with empty string (0x00 0x00) and 0x09
519
+            if (($key == '') && ($this->stream->peekByte() == 0x09)) {
520
+                // Consume byte
521
+                $this->stream->readByte();
522
+                break;
523
+            }
524 524
 
525
-			if (is_numeric($key)) {
526
-				$key = (float) $key;
527
-			}
525
+            if (is_numeric($key)) {
526
+                $key = (float) $key;
527
+            }
528 528
 
529
-			$data[$key] = $this->readData();
530
-		}
529
+            $data[$key] = $this->readData();
530
+        }
531 531
 
532
-		return $data;
533
-	}
532
+        return $data;
533
+    }
534 534
 
535 535
 
536
-	public function readArray() {
536
+    public function readArray() {
537 537
 
538
-		$length = $this->stream->readLong();
538
+        $length = $this->stream->readLong();
539 539
 
540
-		$data = array();
540
+        $data = array();
541 541
 
542
-		for ($i = 0; $i < count($length); $i++) {
543
-			$data[] = $this->readData();
544
-		}
542
+        for ($i = 0; $i < count($length); $i++) {
543
+            $data[] = $this->readData();
544
+        }
545 545
 
546
-		return $data;
547
-	}
546
+        return $data;
547
+    }
548 548
 
549 549
 
550
-	public function readDate() {
550
+    public function readDate() {
551 551
 
552
-		$timestamp = $this->stream->readDouble();
553
-		$timezone = $this->stream->readInt();
554
-		return $timestamp;
555
-	}
552
+        $timestamp = $this->stream->readDouble();
553
+        $timezone = $this->stream->readInt();
554
+        return $timestamp;
555
+    }
556 556
 
557 557
 
558
-	public function readLongString() {
558
+    public function readLongString() {
559 559
 
560
-		return $this->stream->readLongUTF();
561
-	}
560
+        return $this->stream->readLongUTF();
561
+    }
562 562
 
563 563
 
564
-	public function readXML() {
564
+    public function readXML() {
565 565
 
566
-		return $this->stream->readLongUTF();
567
-	}
566
+        return $this->stream->readLongUTF();
567
+    }
568 568
 
569 569
 
570
-	public function readTypedObject() {
570
+    public function readTypedObject() {
571 571
 
572
-		$className = $this->stream->readUTF();
573
-		return $this->readObject();
574
-	}
572
+        $className = $this->stream->readUTF();
573
+        return $this->readObject();
574
+    }
575 575
 }
576 576
 
577 577
 ?>
Please login to merge, or discard this patch.
main/inc/lib/glossary.lib.php 3 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * This functions stores the glossary in the database
87 87
      *
88 88
      * @param array    Array of title + description (glossary_title => $title, glossary_comment => $comment)
89
-     * @return mixed   Term id on success, false on failure
89
+     * @return false|string   Term id on success, false on failure
90 90
      * @author Christian Fasanando <[email protected]>
91 91
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
92 92
      * @version januari 2009, dokeos 1.8.6
@@ -443,6 +443,10 @@  discard block
 block discarded – undo
443 443
      * @param integer Number of items to collect
444 444
      * @param string  Name of column on which to order
445 445
      * @param string  Whether to sort in ascending (ASC) or descending (DESC)
446
+     * @param integer $from
447
+     * @param integer $number_of_items
448
+     * @param integer $column
449
+     * @param string $direction
446 450
      * @return unknown
447 451
      *
448 452
      * @author Patrick Cool <[email protected]>
@@ -520,6 +524,7 @@  discard block
 block discarded – undo
520 524
      * @param integer $glossary_id
521 525
      * @param array   Parameters to use to affect links
522 526
      * @param array   The line of results from a query on the glossary table
527
+     * @param string $url_params
523 528
      * @return string HTML string for the action icons columns
524 529
      *
525 530
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
      * @param int $glossary_id
40 40
      * @return string The glossary description
41 41
      */
42
-    public static function get_glossary_term_by_glossary_id ($glossary_id)
42
+    public static function get_glossary_term_by_glossary_id($glossary_id)
43 43
     {
44
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
44
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
45 45
         $course_id = api_get_course_int_id();
46 46
         $sql = "SELECT description FROM $glossary_table
47 47
                 WHERE c_id = $course_id  AND glossary_id =".intval($glossary_id);
48
-        $rs=Database::query($sql);
48
+        $rs = Database::query($sql);
49 49
         if (Database::num_rows($rs) > 0) {
50 50
             $row = Database::fetch_array($rs);
51 51
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @param string The glossary term name
62 62
      * @return string The glossary description
63 63
      */
64
-    public static function get_glossary_term_by_glossary_name ($glossary_name)
64
+    public static function get_glossary_term_by_glossary_name($glossary_name)
65 65
     {
66
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
66
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
67 67
         $session_id = api_get_session_id();
68 68
         $course_id = api_get_course_int_id();
69 69
         $sql_filter = api_get_session_condition($session_id);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $course_id = api_get_course_int_id();
164 164
 
165 165
         // check if the glossary term already exists
166
-        if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) {
166
+        if (GlossaryManager::glossary_exists($values['glossary_title'], $values['glossary_id'])) {
167 167
             // display the feedback message
168 168
             if ($message)
169 169
                 Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $get_max = "SELECT MAX(display_order) FROM $t_glossary
211 211
                     WHERE c_id = $course_id ";
212 212
         $res_max = Database::query($get_max);
213
-        if (Database::num_rows($res_max)==0) {
213
+        if (Database::num_rows($res_max) == 0) {
214 214
             return 0;
215 215
         }
216 216
         $row = Database::fetch_array($res_max);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
232 232
      * @version januari 2009, dokeos 1.8.6
233 233
      */
234
-    public static function glossary_exists($term, $not_id='')
234
+    public static function glossary_exists($term, $not_id = '')
235 235
     {
236 236
         // Database table definition
237 237
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 WHERE
242 242
                     c_id = $course_id AND
243 243
                     name = '".Database::escape_string($term)."'";
244
-        if ($not_id<>'') {
244
+        if ($not_id <> '') {
245 245
             $sql .= " AND glossary_id <> '".intval($not_id)."'";
246 246
         }
247 247
         $result = Database::query($sql);
@@ -347,27 +347,27 @@  discard block
 block discarded – undo
347 347
         // action links
348 348
         echo '<div class="actions">';
349 349
 
350
-        if (api_is_allowed_to_edit(null,true)) {
350
+        if (api_is_allowed_to_edit(null, true)) {
351 351
             echo '<a href="index.php?'.api_get_cidreq().'&action=addglossary&msg=add?'.api_get_cidreq().'">'.
352
-                Display::return_icon('new_glossary_term.png',get_lang('TermAddNew'),'', ICON_SIZE_MEDIUM).'</a>';
352
+                Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>';
353 353
         }
354 354
 
355 355
         echo '<a href="index.php?'.api_get_cidreq().'&action=export">'.
356
-            Display::return_icon('export_csv.png',get_lang('ExportGlossaryAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
357
-        if (api_is_allowed_to_edit(null,true)) {
356
+            Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
357
+        if (api_is_allowed_to_edit(null, true)) {
358 358
             echo '<a href="index.php?'.api_get_cidreq().'&action=import">'.
359
-                Display::return_icon('import_csv.png',get_lang('ImportGlossary'),'',ICON_SIZE_MEDIUM).'</a>';
359
+                Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>';
360 360
         }
361 361
 
362 362
         echo '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf">'.
363
-            Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>';
363
+            Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
364 364
 
365
-        if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))){
365
+        if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))) {
366 366
             echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=list">'.
367
-                Display::return_icon('view_detailed.png',get_lang('ListView'),'',ICON_SIZE_MEDIUM).'</a>';
367
+                Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>';
368 368
         } else {
369 369
             echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=table">'.
370
-                Display::return_icon('view_text.png',get_lang('TableView'),'',ICON_SIZE_MEDIUM).'</a>';
370
+                Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>';
371 371
         }
372 372
         echo '</div>';
373 373
         if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
             //$table->set_header(0, '', false);
381 381
             $table->set_header(0, get_lang('TermName'), true);
382 382
             $table->set_header(1, get_lang('TermDefinition'), true);
383
-            if (api_is_allowed_to_edit(null,true)) {
383
+            if (api_is_allowed_to_edit(null, true)) {
384 384
                 $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions'));
385
-                $table->set_column_filter(2, array('GlossaryManager','actions_filter'));
385
+                $table->set_column_filter(2, array('GlossaryManager', 'actions_filter'));
386 386
             }
387 387
             $table->display();
388 388
         }
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
      */
400 400
     public static function display_glossary_list()
401 401
     {
402
-        $glossary_data = self::get_glossary_data(0,1000,0,'ASC');
402
+        $glossary_data = self::get_glossary_data(0, 1000, 0, 'ASC');
403 403
         foreach ($glossary_data as $key => $glossary_item) {
404 404
             $actions = '';
405
-            if (api_is_allowed_to_edit(null,true)) {
406
-                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>';
405
+            if (api_is_allowed_to_edit(null, true)) {
406
+                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '', $glossary_item).'</div>';
407 407
             }
408 408
             echo Display::panel($glossary_item[1], $glossary_item[0].' '.$actions);
409 409
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
419 419
      * @version januari 2009, dokeos 1.8.6
420 420
      */
421
-    public static  function get_number_glossary_terms($session_id=0)
421
+    public static  function get_number_glossary_terms($session_id = 0)
422 422
     {
423 423
         // Database table definition
424 424
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
457 457
         $t_item_propery = Database :: get_course_table(TABLE_ITEM_PROPERTY);
458 458
 
459
-        if (api_is_allowed_to_edit(null,true)) {
459
+        if (api_is_allowed_to_edit(null, true)) {
460 460
             $col2 = " glossary.glossary_id	as col2, ";
461 461
         } else {
462 462
             $col2 = " ";
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
             'glossary.session_id'
472 472
         );
473 473
         $column = intval($column);
474
-        if (!in_array($direction,array('DESC', 'ASC'))) {
475
-            $direction          = 'ASC';
474
+        if (!in_array($direction, array('DESC', 'ASC'))) {
475
+            $direction = 'ASC';
476 476
         }
477 477
         $from = intval($from);
478 478
         $number_of_items = intval($number_of_items);
@@ -497,15 +497,15 @@  discard block
 block discarded – undo
497 497
         while ($data = Database::fetch_array($res)) {
498 498
             // Validation when belongs to a session
499 499
             $session_img = api_get_session_image($data['session_id'], $_user['status']);
500
-            $array[0] = $data[0] . $session_img;
500
+            $array[0] = $data[0].$session_img;
501 501
 
502 502
             if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
503
-                $array[1] = str_replace(array('<p>','</p>'),array('','<br />'),$data[1]);
503
+                $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
504 504
             } else {
505 505
                 $array[1] = $data[1];
506 506
             }
507 507
 
508
-            if (api_is_allowed_to_edit(null,true)) {
508
+            if (api_is_allowed_to_edit(null, true)) {
509 509
                 $array[2] = $data[2];
510 510
             }
511 511
             $return[] = $array;
@@ -528,14 +528,14 @@  discard block
 block discarded – undo
528 528
     public static function actions_filter($glossary_id, $url_params, $row)
529 529
     {
530 530
         $glossary_id = $row[2];
531
-        $return = '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
531
+        $return = '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
532 532
         $glossary_data = GlossaryManager::get_glossary_information($glossary_id);
533 533
 
534 534
         $glossary_term = $glossary_data['glossary_title'];
535 535
 
536 536
         if (api_is_allowed_to_edit(null, true)) {
537 537
             if ($glossary_data['session_id'] == api_get_session_id()) {
538
-                $return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>';
538
+                $return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a>';
539 539
             } else {
540 540
                 $return  = get_lang('EditionNotAvailableFromSession');
541 541
             }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     {
557 557
         return "<script type=\"text/javascript\">
558 558
 				function confirmation (name) {
559
-					if (confirm(\" ". get_lang("TermConfirmDelete") ." \"+ name + \" ?\"))
559
+					if (confirm(\" ". get_lang("TermConfirmDelete")." \"+ name + \" ?\"))
560 560
 						{return true;}
561 561
 					else
562 562
 						{return false;}
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         $res = Database::query($sql);
617 617
         $found = false;
618 618
         while ($row = Database::fetch_array($res)) {
619
-            if ($found && empty($next_id))	{
619
+            if ($found && empty($next_id)) {
620 620
                 $next_id = $row['glossary_id'];
621 621
                 $next_display_order = $row['display_order'];
622 622
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@  discard block
 block discarded – undo
108 108
         // check if the glossary term already exists
109 109
         if (GlossaryManager::glossary_exists($values['glossary_title'])) {
110 110
             // display the feedback message
111
-            if ($message)
112
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
111
+            if ($message) {
112
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
113
+            }
113 114
             return false;
114 115
         } else {
115 116
 
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
         // check if the glossary term already exists
166 167
         if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) {
167 168
             // display the feedback message
168
-            if ($message)
169
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
169
+            if ($message) {
170
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
171
+            }
170 172
             return false;
171 173
         } else {
172 174
             $sql = "UPDATE $t_glossary SET
@@ -188,8 +190,9 @@  discard block
 block discarded – undo
188 190
                 api_get_user_id()
189 191
             );
190 192
             // display the feedback message
191
-            if ($message)
192
-                Display::display_confirmation_message(get_lang('TermUpdated'));
193
+            if ($message) {
194
+                            Display::display_confirmation_message(get_lang('TermUpdated'));
195
+            }
193 196
         }
194 197
 
195 198
         return true;
@@ -323,8 +326,9 @@  discard block
 block discarded – undo
323 326
         // reorder the remaining terms
324 327
         GlossaryManager::reorder_glossary();
325 328
         $_SESSION['max_glossary_display'] = GlossaryManager::get_max_glossary_item();
326
-        if ($message)
327
-            Display::display_confirmation_message(get_lang('TermDeleted'));
329
+        if ($message) {
330
+                    Display::display_confirmation_message(get_lang('TermDeleted'));
331
+        }
328 332
         return true;
329 333
     }
330 334
 
@@ -633,8 +637,9 @@  discard block
 block discarded – undo
633 637
                  WHERE c_id = $course_id  AND glossary_id = '".Database::escape_string($next_id)."'";
634 638
         Database::query($sql1);
635 639
         Database::query($sql2);
636
-        if ($message)
637
-            Display::display_confirmation_message(get_lang('TermMoved'));
640
+        if ($message) {
641
+                    Display::display_confirmation_message(get_lang('TermMoved'));
642
+        }
638 643
     }
639 644
 
640 645
     /**
Please login to merge, or discard this patch.
main/inc/lib/grade_model.lib.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -248,6 +248,9 @@
 block discarded – undo
248 248
 	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
249 249
     }
250 250
 
251
+    /**
252
+     * @param CatForm $form
253
+     */
251 254
     public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null)
252 255
     {
253 256
         if (api_get_setting('gradebook_enable_grade_model') == 'false') {
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * Displays the title + grid
52 52
      */
53
-	public function display()
53
+    public function display()
54 54
     {
55
-		// action links
56
-		echo '<div class="actions" style="margin-bottom:20px">';
55
+        // action links
56
+        echo '<div class="actions" style="margin-bottom:20px">';
57 57
         echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
58
-		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
59
-		echo '</div>';
58
+        echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
59
+        echo '</div>';
60 60
         echo Display::grid_html('grade_model');
61
-	}
61
+    }
62 62
 
63 63
     /**
64 64
      * Returns a Form validator Obj
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
         $form->addElement('hidden', 'maxvalue', '100');
118
-		$form->addElement('hidden', 'minvalue', '0');
118
+        $form->addElement('hidden', 'minvalue', '0');
119 119
         $renderer = & $form->defaultRenderer();
120 120
 
121 121
         $component_array = array();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             $form->addElement('text', 'components['.$i.'][title]',      null);
128 128
             $form->addElement('hidden', 'components['.$i.'][id]',       null);
129 129
 
130
-             $template_percentage =
130
+                $template_percentage =
131 131
             '<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
132 132
                 <p>
133 133
                 <label class="control-label">{label}</label>
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         // Setting the rules
193 193
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
194 194
 
195
-		return $form;
195
+        return $form;
196 196
     }
197 197
 
198 198
     public function get_components($id)
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 
207 207
     public function save($params, $show_query = false)
208 208
     {
209
-	    $id = parent::save($params, $show_query);
210
-	    if (!empty($id)) {
209
+        $id = parent::save($params, $show_query);
210
+        if (!empty($id)) {
211 211
             foreach ($params['components'] as $component) {
212 212
                 if (!empty($component['title']) && !empty($component['percentage']) && !empty($component['acronym'])) {
213 213
                     $obj = new GradeModelComponents();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
221
-   		return $id;
221
+            return $id;
222 222
     }
223 223
 
224 224
     /**
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 
245 245
     public function delete($id)
246 246
     {
247
-	    parent::delete($id);
248
-	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
247
+        parent::delete($id);
248
+        //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
249 249
     }
250 250
 
251 251
     public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null)
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
     public $table;
291 291
     public $columns = array('id', 'title', 'percentage', 'acronym', 'grade_model_id');
292 292
 
293
-	public function __construct()
293
+    public function __construct()
294 294
     {
295 295
         $this->table =  Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
296
-	}
296
+    }
297 297
 
298 298
     public function save($params, $show_query = false)
299 299
     {
300
-	    $id = parent::save($params, $show_query);
300
+        $id = parent::save($params, $show_query);
301 301
         return $id;
302 302
     }
303 303
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      */
16 16
     public function __construct()
17 17
     {
18
-        $this->table =  Database::get_main_table(TABLE_GRADE_MODEL);
18
+        $this->table = Database::get_main_table(TABLE_GRADE_MODEL);
19 19
     }
20 20
 
21 21
     /**
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     {
55 55
 		// action links
56 56
 		echo '<div class="actions" style="margin-bottom:20px">';
57
-        echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
58
-		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
57
+        echo '<a href="grade_models.php">'.Display::return_icon('back.png', get_lang('Back'), '', '32').'</a>';
58
+		echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
59 59
 		echo '</div>';
60 60
         echo Display::grid_html('grade_model');
61 61
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         if ($action == 'edit') {
112 112
             if (!empty($components)) {
113
-                $nr_items = count($components) -1;
113
+                $nr_items = count($components) - 1;
114 114
             }
115 115
         }
116 116
 
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
         for ($i = 0; $i <= $max; $i++) {
124 124
             $counter = $i;
125 125
             $form->addElement('text', 'components['.$i.'][percentage]', null);
126
-            $form->addElement('text', 'components['.$i.'][acronym]',    null);
127
-            $form->addElement('text', 'components['.$i.'][title]',      null);
128
-            $form->addElement('hidden', 'components['.$i.'][id]',       null);
126
+            $form->addElement('text', 'components['.$i.'][acronym]', null);
127
+            $form->addElement('text', 'components['.$i.'][title]', null);
128
+            $form->addElement('hidden', 'components['.$i.'][id]', null);
129 129
 
130 130
              $template_percentage =
131
-            '<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
131
+            '<div id='.$i.' style="display: '.(($i <= $nr_items) ? 'inline' : 'none').';" class="control-group">
132 132
                 <p>
133 133
                 <label class="control-label">{label}</label>
134 134
                 <div class="controls">
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 
142 142
             $template_title =
143 143
             '&nbsp{element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error -->
144
-             <a href="javascript:plusItem(' . ($counter+1) . ')">
145
-                <img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="'.Display::return_icon('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'">
144
+             <a href="javascript:plusItem(' . ($counter + 1).')">
145
+                <img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="plus-'.($counter + 1).'" src="'.Display::return_icon('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'">
146 146
             </a>
147
-            <a href="javascript:minItem(' . ($counter) . ')">
148
-                <img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="min-' . $counter . '" src="'.Display::return_icon('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'">
147
+            <a href="javascript:minItem(' . ($counter).')">
148
+                <img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="min-'.$counter.'" src="'.Display::return_icon('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'">
149 149
             </a>
150 150
             </div></p></div>';
151 151
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 	public function __construct()
294 294
     {
295
-        $this->table =  Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
295
+        $this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
296 296
 	}
297 297
 
298 298
     public function save($params, $show_query = false)
Please login to merge, or discard this patch.
main/inc/lib/group_portal_manager.lib.php 4 patches
Doc Comments   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param	int		$visibility is active or not
22 22
      * @param   string  $picture
23 23
      *
24
-     * @return boolean if success
24
+     * @return string|false if success
25 25
      */
26 26
     public static function add($name, $description, $url, $visibility, $picture = '')
27 27
     {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param int $visibility
58 58
      * @param string $picture_uri
59 59
      * @param bool $allowMemberGroupToLeave
60
-     * @return bool if success
60
+     * @return Statement|null if success
61 61
      */
62 62
     public static function update($group_id, $name, $description, $url, $visibility, $picture_uri, $allowMemberGroupToLeave = null)
63 63
     {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * Deletes a group
88 88
      * @author Julio Montoya
89 89
      * @param int $id
90
-     * @return boolean true if success
90
+     * @return Statement|null true if success
91 91
      * */
92 92
     public static function delete($id)
93 93
     {
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      * @param int $group_id
176 176
      * @param int $parent_group_id if 0, we delete the parent_group association
177 177
      * @param int $relation_type
178
-     * @return resource
178
+     * @return Statement|null
179 179
      **/
180 180
     public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1)
181 181
     {
@@ -652,6 +652,7 @@  discard block
 block discarded – undo
652 652
      * @author Julio Montoya
653 653
      * @param  int user_id
654 654
      * @param  int url_id
655
+     * @param integer $relation_type
655 656
      * @return boolean true if success
656 657
      **/
657 658
     public static function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
@@ -735,7 +736,7 @@  discard block
 block discarded – undo
735 736
      * @author Julio Montoya
736 737
      * @param int $group_id
737 738
      * @param int $relation_type (optional)
738
-     * @return boolean true if success
739
+     * @return Statement|null true if success
739 740
      * */
740 741
     public static function delete_users($group_id, $relation_type = null)
741 742
     {
@@ -916,6 +917,7 @@  discard block
 block discarded – undo
916 917
      * If an empty name is provided, then old user photos are deleted only, @see UserManager::delete_user_picture()
917 918
      * as the prefered way for deletion.
918 919
      * @param	string		$source_file The full system name of the image from which user photos will be created.
920
+     * @param integer $group_id
919 921
      * @return	string/bool	Returns the resulting file name of created images which usually should be stored in DB.
920 922
      * When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
921 923
      */
@@ -1074,7 +1076,9 @@  discard block
 block discarded – undo
1074 1076
      *
1075 1077
      * @param  string file picture
1076 1078
      * @param  int size in pixels
1077
-     * @return obj image object
1079
+     * @param string|null $file
1080
+     * @param integer $max_size_for_picture
1081
+     * @return Image image object
1078 1082
      */
1079 1083
     public static function resize_picture($file, $max_size_for_picture)
1080 1084
     {
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1335,27 +1335,27 @@
 block discarded – undo
1335 1335
     public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
1336 1336
     {
1337 1337
         $table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
1338
-		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
1339
-		$user_id = intval($user_id);
1338
+        $tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
1339
+        $user_id = intval($user_id);
1340 1340
 
1341
-		if ($relation_type == 0) {
1342
-			$where_relation_condition = '';
1343
-		} else {
1344
-			$relation_type 			= intval($relation_type);
1345
-			$where_relation_condition = "AND gu.relation_type = $relation_type ";
1346
-		}
1341
+        if ($relation_type == 0) {
1342
+            $where_relation_condition = '';
1343
+        } else {
1344
+            $relation_type 			= intval($relation_type);
1345
+            $where_relation_condition = "AND gu.relation_type = $relation_type ";
1346
+        }
1347 1347
 
1348
-		$sql = "SELECT count(g.id) as count
1348
+        $sql = "SELECT count(g.id) as count
1349 1349
 				FROM $tbl_group g
1350 1350
 				INNER JOIN $table_group_rel_user gu
1351 1351
 				ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ";
1352 1352
 
1353
-		$result = Database::query($sql);
1354
-		if (Database::num_rows($result) > 0) {
1355
-			$row = Database::fetch_array($result, 'ASSOC');
1353
+        $result = Database::query($sql);
1354
+        if (Database::num_rows($result) > 0) {
1355
+            $row = Database::fetch_array($result, 'ASSOC');
1356 1356
             return $row['count'];
1357
-		}
1358
-		return 0;
1357
+        }
1358
+        return 0;
1359 1359
     }
1360 1360
 
1361 1361
     /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             if ($i == $max_level) {
332 332
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
333 333
             } else {
334
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
334
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
335 335
             }
336 336
             if ($i == 1) {
337 337
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
@@ -1334,14 +1334,14 @@  discard block
 block discarded – undo
1334 1334
      */
1335 1335
     public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
1336 1336
     {
1337
-        $table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
1338
-		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
1337
+        $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
1338
+		$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
1339 1339
 		$user_id = intval($user_id);
1340 1340
 
1341 1341
 		if ($relation_type == 0) {
1342 1342
 			$where_relation_condition = '';
1343 1343
 		} else {
1344
-			$relation_type 			= intval($relation_type);
1344
+			$relation_type = intval($relation_type);
1345 1345
 			$where_relation_condition = "AND gu.relation_type = $relation_type ";
1346 1346
 		}
1347 1347
 
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 
1395 1395
         // Picture
1396 1396
         $form->addElement('file', 'picture', get_lang('AddPicture'));
1397
-        $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
1397
+        $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
1398 1398
         $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
1399 1399
 
1400 1400
         if (!empty($groupData)) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -563,8 +563,9 @@  discard block
 block discarded – undo
563 563
                 $new_relation_type[] = "'$rel'";
564 564
             }
565 565
             $relation_type = implode(',', $new_relation_type);
566
-            if (!empty($relation_type))
567
-                $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
566
+            if (!empty($relation_type)) {
567
+                            $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
568
+            }
568 569
         }
569 570
 
570 571
         $sql = "SELECT
@@ -1086,8 +1087,9 @@  discard block
 block discarded – undo
1086 1087
                 $thumbwidth = $max_size_for_picture;
1087 1088
             }
1088 1089
             $new_height = round(($thumbwidth / $picture_infos['width']) * $picture_infos['height']);
1089
-            if ($new_height > $max_size_for_picture)
1090
-                $new_height = $thumbwidth;
1090
+            if ($new_height > $max_size_for_picture) {
1091
+                            $new_height = $thumbwidth;
1092
+            }
1091 1093
             $temp->resize($thumbwidth, $new_height, 0);
1092 1094
         }
1093 1095
 
Please login to merge, or discard this patch.
main/inc/lib/groupmanager.lib.php 2 patches
Doc Comments   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * @author Christophe Gesche <[email protected]>
370 370
      * @author Hugues Peeters <[email protected]>
371 371
      * @author Bart Mollet
372
-     * @param  mixed  $groupIdList - group(s) to delete. It can be a single id
372
+     * @param  mixed  $group_ids - group(s) to delete. It can be a single id
373 373
      *                                (int) or a list of id (array).
374 374
      * @param string $course_code Default is current course
375 375
      * @return integer              - number of groups deleted.
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
      * @param bool      Whether self registration is allowed or not
574 574
      * @param bool      Whether self unregistration is allowed or not
575 575
      * @param int       $categoryId
576
-     * @return bool     TRUE if properties are successfully changed, false otherwise
576
+     * @return Statement|null     TRUE if properties are successfully changed, false otherwise
577 577
      */
578 578
     public static function set_group_properties(
579 579
         $group_id,
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      * @param int $group_id The id of the group
725 725
      * @param string $course_code The course in which the group is (default =
726 726
      * current course)
727
-     * @return array The category
727
+     * @return integer The category
728 728
      */
729 729
     public static function get_category_from_group($group_id, $course_code = null)
730 730
     {
@@ -786,9 +786,9 @@  discard block
 block discarded – undo
786 786
      * Create group category
787 787
      * @param string $title The title of the new category
788 788
      * @param string $description The description of the new category
789
-     * @param bool $self_registration_allowed
790
-     * @param bool $self_unregistration_allowed
791
-     * @param int $max_number_of_students
789
+     * @param integer $self_registration_allowed
790
+     * @param integer $self_unregistration_allowed
791
+     * @param int $maximum_number_of_students
792 792
      * @param int $groups_per_user
793 793
      */
794 794
     public static function create_category(
@@ -994,6 +994,8 @@  discard block
 block discarded – undo
994 994
      * @param int $limit
995 995
      * @param bool $getCount
996 996
      * @param int $courseId
997
+     * @param string $column
998
+     * @param string $direction
997 999
      * @return array list of user id
998 1000
      */
999 1001
     public static function get_users(
@@ -1172,7 +1174,7 @@  discard block
 block discarded – undo
1172 1174
      *         Hugues Peeters     <[email protected]> - original version
1173 1175
      * @author Roan Embrechts - virtual course support, code cleaning
1174 1176
      * @author Bart Mollet - code cleaning, use other GroupManager-functions
1175
-     * @return void
1177
+     * @return false|null
1176 1178
      */
1177 1179
     public static function fill_groups($group_ids)
1178 1180
     {
@@ -1625,7 +1627,7 @@  discard block
 block discarded – undo
1625 1627
      * Unsubscribe user(s) from a specified group in current course
1626 1628
      * @param mixed $user_ids Can be an array with user-id's or a single user-id
1627 1629
      * @param int $group_id
1628
-     * @return bool TRUE if successful
1630
+     * @return boolean|null TRUE if successful
1629 1631
      */
1630 1632
     public static function unsubscribe_users($user_ids, $group_id)
1631 1633
     {
@@ -1644,7 +1646,7 @@  discard block
 block discarded – undo
1644 1646
 
1645 1647
     /**
1646 1648
      * Unsubscribe all users from one or more groups
1647
-     * @param mixed $group_id Can be an array with group-id's or a single group-id
1649
+     * @param mixed $group_ids Can be an array with group-id's or a single group-id
1648 1650
      * @return bool TRUE if successful
1649 1651
      */
1650 1652
     public static function unsubscribe_all_users($group_ids)
@@ -1676,7 +1678,7 @@  discard block
 block discarded – undo
1676 1678
 
1677 1679
     /**
1678 1680
      * Unsubscribe all tutors from one or more groups
1679
-     * @param mixed $group_id Can be an array with group-id's or a single group-id
1681
+     * @param mixed $group_ids Can be an array with group-id's or a single group-id
1680 1682
      * @see unsubscribe_all_users. This function is almost an exact copy of that function.
1681 1683
      * @return bool TRUE if successful
1682 1684
      * @author Patrick Cool <[email protected]>, Ghent University
@@ -1861,6 +1863,7 @@  discard block
 block discarded – undo
1861 1863
      *
1862 1864
      * @param $user_array_in list of users (must be sorted).
1863 1865
      * @param string $compare_field, the field to be compared
1866
+     * @param string $compare_field
1864 1867
      */
1865 1868
     public static function filter_duplicates($user_array_in, $compare_field)
1866 1869
     {
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
             $sql = "UPDATE $table_group SET id = iid WHERE iid = $lastId";
222 222
             Database::query($sql);
223 223
 
224
-            $desired_dir_name= '/'.api_replace_dangerous_char($name).'_groupdocs';
225
-            $my_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository . '/document';
224
+            $desired_dir_name = '/'.api_replace_dangerous_char($name).'_groupdocs';
225
+            $my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document';
226 226
 
227 227
             $newFolderData = create_unexisting_directory(
228 228
                 $_course,
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
                 $values['default_view_type_group']['default_view_type'] = api_get_setting('default_forum_view');
286 286
                 $values['group_forum'] = $lastId;
287 287
                 if ($forumState == '1') {
288
-                    $values['public_private_group_forum_group']['public_private_group_forum']='public';
288
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'public';
289 289
                 } elseif ($forumState == '2') {
290
-                    $values['public_private_group_forum_group']['public_private_group_forum']='private';
290
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'private';
291 291
                 } elseif ($forumState == '0') {
292
-                    $values['public_private_group_forum_group']['public_private_group_forum']='unavailable';
292
+                    $values['public_private_group_forum_group']['public_private_group_forum'] = 'unavailable';
293 293
                 }
294 294
                 store_forum($values);
295 295
             }
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
             1
321 321
         );
322 322
         $users = self::get_users($group_id);
323
-        $group_ids = array ();
323
+        $group_ids = array();
324 324
 
325
-        for ($group_nr = 1; $group_nr <= $number_of_groups; $group_nr ++) {
325
+        for ($group_nr = 1; $group_nr <= $number_of_groups; $group_nr++) {
326 326
             $group_ids[] = self::create_group(
327 327
                 get_lang('Subgroup').' '.$group_nr,
328 328
                 $category_id,
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 0,
367 367
                 count($users_ids)
368 368
             );
369
-            self::subscribe_users($users_ids,$group_id);
369
+            self::subscribe_users($users_ids, $group_id);
370 370
             $group_ids[] = $group_id;
371 371
         }
372 372
         return $group_ids;
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
         $group_table = Database:: get_course_table(TABLE_GROUP);
392 392
         $forum_table = Database:: get_course_table(TABLE_FORUM);
393 393
 
394
-        $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
395
-        $group_ids = array_map('intval',$group_ids);
394
+        $group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
395
+        $group_ids = array_map('intval', $group_ids);
396 396
 
397 397
         if (api_is_course_coach()) {
398 398
             //a coach can only delete courses from his session
399
-            for ($i=0 ; $i<count($group_ids) ; $i++) {
400
-                if (!api_is_element_in_the_session(TOOL_GROUP,$group_ids[$i])) {
401
-                    array_splice($group_ids,$i,1);
399
+            for ($i = 0; $i < count($group_ids); $i++) {
400
+                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
401
+                    array_splice($group_ids, $i, 1);
402 402
                     $i--;
403 403
                 }
404 404
             }
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
         } elseif ($forum_state === 0) {
634 634
             $sql2 .= " forum_group_public_private='unavailable' ";
635 635
         }
636
-        $sql2 .=" WHERE c_id = $course_id AND forum_of_group=".$group_id;
636
+        $sql2 .= " WHERE c_id = $course_id AND forum_of_group=".$group_id;
637 637
         Database::query($sql2);
638 638
         return $result;
639 639
     }
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
     public static function get_categories($course_code = null)
663 663
     {
664 664
         $course_info = api_get_course_info($course_code);
665
-        $course_id     = $course_info['real_id'];
665
+        $course_id = $course_info['real_id'];
666 666
         $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY);
667 667
         $sql = "SELECT * FROM $table_group_cat
668 668
                 WHERE c_id = $course_id
669 669
                 ORDER BY display_order";
670 670
         $res = Database::query($sql);
671
-        $cats = array ();
671
+        $cats = array();
672 672
         while ($cat = Database::fetch_array($res)) {
673 673
             $cats[] = $cat;
674 674
         }
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
                 WHERE c_id = $course_id AND category_id='".$cat_id."'";
780 780
         $res = Database::query($sql);
781 781
         if (Database::num_rows($res) > 0) {
782
-            $groups_to_delete = array ();
782
+            $groups_to_delete = array();
783 783
             while ($group = Database::fetch_object($res)) {
784 784
                 $groups_to_delete[] = $group->id;
785 785
             }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
      */
948 948
     public static function get_current_max_groups_per_user($category_id = null, $course_code = null)
949 949
     {
950
-        $course_info = api_get_course_info ($course_code);
950
+        $course_info = api_get_course_info($course_code);
951 951
         $group_table = Database :: get_course_table(TABLE_GROUP);
952 952
         $group_user_table = Database :: get_course_table(TABLE_GROUP_USER);
953 953
         $sql = 'SELECT COUNT(gu.group_id) AS current_max
@@ -1186,17 +1186,17 @@  discard block
 block discarded – undo
1186 1186
     {
1187 1187
         $_course = api_get_course_info();
1188 1188
 
1189
-        $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
1189
+        $group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
1190 1190
         $group_ids = array_map('intval', $group_ids);
1191 1191
 
1192 1192
         if (api_is_course_coach()) {
1193
-            for ($i=0 ; $i< count($group_ids) ; $i++) {
1194
-                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])){
1195
-                    array_splice($group_ids,$i,1);
1193
+            for ($i = 0; $i < count($group_ids); $i++) {
1194
+                if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
1195
+                    array_splice($group_ids, $i, 1);
1196 1196
                     $i--;
1197 1197
                 }
1198 1198
             }
1199
-            if (count($group_ids)==0) {
1199
+            if (count($group_ids) == 0) {
1200 1200
                 return false;
1201 1201
             }
1202 1202
         }
@@ -1235,9 +1235,9 @@  discard block
 block discarded – undo
1235 1235
          * Retrieve course users (reverse) ordered by the number
1236 1236
          * of group they are already enrolled
1237 1237
          */
1238
-        for ($i = 0; $i < count($complete_user_list); $i ++) {
1238
+        for ($i = 0; $i < count($complete_user_list); $i++) {
1239 1239
             //find # of groups the user is enrolled in
1240
-            $number_of_groups = self :: user_in_number_of_groups($complete_user_list[$i]["user_id"], (isset($category['id'])?$category['id']:null));
1240
+            $number_of_groups = self :: user_in_number_of_groups($complete_user_list[$i]["user_id"], (isset($category['id']) ? $category['id'] : null));
1241 1241
             //add # of groups to user list
1242 1242
             $complete_user_list[$i]['number_groups_left'] = $number_groups_per_user - $number_of_groups;
1243 1243
         }
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
         //now sort by # of group left
1251 1251
         $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC);
1252
-        $userToken = array ();
1252
+        $userToken = array();
1253 1253
         foreach ($complete_user_list as $this_user) {
1254 1254
             if ($this_user['number_groups_left'] > 0) {
1255 1255
                 $userToken[$this_user['user_id']] = $this_user['number_groups_left'];
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
                 if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) {
1445 1445
                     $category['groups_per_user'] = self::INFINITE;
1446 1446
                 }
1447
-                $result = self:: user_in_number_of_groups($user_id, $category['id'] ) < $category['groups_per_user'];
1447
+                $result = self:: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user'];
1448 1448
                 if ($result == false) {
1449 1449
                     return false;
1450 1450
                 }
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
                     tg.group_id='".$group_id."' AND
1556 1556
                     tg.user_id=u.user_id".$order_clause;
1557 1557
         $db_result = Database::query($sql);
1558
-        $users = array ();
1558
+        $users = array();
1559 1559
         while ($user = Database::fetch_object($db_result)) {
1560 1560
             if (!$id_only) {
1561 1561
                 $member['user_id'] = $user->user_id;
@@ -1620,8 +1620,8 @@  discard block
 block discarded – undo
1620 1620
         foreach ($user_ids as $user_id) {
1621 1621
             $user_id = intval($user_id);
1622 1622
             if (self::can_user_subscribe($user_id, $group_id, false)) {
1623
-                $sql = "INSERT INTO " . $table_group_tutor . " (c_id, user_id, group_id)
1624
-                        VALUES ('$course_id', '" . $user_id . "', '" . $group_id . "')";
1623
+                $sql = "INSERT INTO ".$table_group_tutor." (c_id, user_id, group_id)
1624
+                        VALUES ('$course_id', '".$user_id."', '".$group_id."')";
1625 1625
                 $result &= Database::query($sql);
1626 1626
             }
1627 1627
         }
@@ -1637,7 +1637,7 @@  discard block
 block discarded – undo
1637 1637
      */
1638 1638
     public static function unsubscribe_users($user_ids, $group_id)
1639 1639
     {
1640
-        $user_ids = is_array($user_ids) ? $user_ids : array ($user_ids);
1640
+        $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
1641 1641
         $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
1642 1642
         $group_id = intval($group_id);
1643 1643
         $course_id = api_get_course_int_id();
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
          * Retrieve course users (reverse) ordered by the number
2184 2184
          * of group they are already enrolled
2185 2185
          */
2186
-        for ($i = 0; $i < count($complete_user_list); $i ++) {
2186
+        for ($i = 0; $i < count($complete_user_list); $i++) {
2187 2187
             // find # of groups the user is enrolled in
2188 2188
             $number_of_groups = self:: user_in_number_of_groups(
2189 2189
                 $complete_user_list[$i]["user_id"],
@@ -2315,14 +2315,14 @@  discard block
 block discarded – undo
2315 2315
                 !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
2316 2316
             ) {
2317 2317
                 $edit_actions = '<a href="'.$url.'settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'"  title="'.get_lang('Edit').'">'.
2318
-                    Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2318
+                    Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2319 2319
 
2320 2320
                 if ($this_group['status'] == 1) {
2321
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&action=set_invisible&id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
2322
-                        Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
2321
+                    $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_invisible&id='.$this_group['id'].'" title="'.get_lang('Hide').'">'.
2322
+                        Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2323 2323
                 } else {
2324
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_visible&id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
2325
-                        Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
2324
+                    $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=set_visible&id='.$this_group['id'].'" title="'.get_lang('Show').'">'.
2325
+                        Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2326 2326
                 }
2327 2327
 
2328 2328
                 $edit_actions .= '<a href="'.$url.'member_settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'"  title="'.get_lang('GroupMembers').'">'.
@@ -2335,10 +2335,10 @@  discard block
 block discarded – undo
2335 2335
                     Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
2336 2336
 
2337 2337
                 $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
2338
-                    Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2338
+                    Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2339 2339
 
2340 2340
                 $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
2341
-                    Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
2341
+                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
2342 2342
 
2343 2343
                 $row[] = $edit_actions;
2344 2344
             }
@@ -2710,7 +2710,7 @@  discard block
 block discarded – undo
2710 2710
         $activeTutor = null;
2711 2711
         $activeMember = null;
2712 2712
 
2713
-        switch($default) {
2713
+        switch ($default) {
2714 2714
             case 'settings':
2715 2715
                 $activeSettings = 'active';
2716 2716
                 break;
Please login to merge, or discard this patch.
main/inc/lib/hook/HookManagement.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 
139 139
     /**
140 140
      * Return a list an associative array where keys are the active hook observer class name
141
-     * @param $eventName
141
+     * @param string $eventName
142 142
      *
143 143
      * @return array
144 144
      */
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     public function listHookObservers($eventName)
146 146
     {
147 147
         $array = array();
148
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
149
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
150
-            ' ON hc.hook_event_id = he.id ' .
151
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
148
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
149
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
150
+            ' ON hc.hook_event_id = he.id '.
151
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
152 152
             ' ON hc.hook_observer_id = ho.id ';
153 153
         $columns = 'ho.class_name, ho.path, ho.plugin_name, hc.enabled';
154 154
         $where = array('where' => array('he.class_name = ? ' => $eventName, 'AND hc.enabled = ? ' => 1));
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
     public function listAllHookCalls()
203 203
     {
204 204
         $array = array();
205
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
206
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
207
-            ' ON hc.hook_event_id = he.id ' .
208
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
205
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
206
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
207
+            ' ON hc.hook_event_id = he.id '.
208
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
209 209
             ' ON hc.hook_observer_id = ho.id ';
210 210
         $columns = 'he.class_name AS event_class_name, ho.class_name AS observer_class_name, hc.id AS id, hc.type AS type';
211 211
         $rows = Database::select($columns, $joinTable);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         if (isset($eventName) && !isset($this->hookEvents[$eventName])) {
232 232
             $attributes = array(
233 233
                 'class_name' => $eventName,
234
-                'description' => get_lang('HookDescription' . $eventName),
234
+                'description' => get_lang('HookDescription'.$eventName),
235 235
             );
236 236
             $id = Database::insert($this->tables[TABLE_HOOK_EVENT], $attributes);
237 237
             $this->hookEvents[$eventName] = $id;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         // Check if exists hook observer
241 241
         if (isset($observerClassName) &&
242 242
             !isset($this->hookObservers[$observerClassName])
243
-        ){
243
+        ) {
244 244
             $object = $observerClassName::create();
245 245
             $attributes = array(
246 246
                 'class_name' => $observerClassName,
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
         $eventName = Database::escape_string($eventName);
339 339
         $observerClassName($observerClassName);
340 340
         $type = Database::escape_string($type);
341
-        $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' .
342
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' .
343
-            ' ON hc.hook_event_id = he.id ' .
344
-            ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' .
341
+        $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'.
342
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'.
343
+            ' ON hc.hook_event_id = he.id '.
344
+            ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '.
345 345
             ' ON hc.hook_observer_id = ho.id ';
346 346
         $row = Database::select(
347 347
             'id',
Please login to merge, or discard this patch.
main/inc/lib/icalcreator/iCalcreator.class.php 4 patches
Doc Comments   +25 added lines, -30 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  * @author Kjell-Inge Gustafsson <[email protected]>
138 138
  * @since 2.4.8 - 2008-10-21
139 139
  * @param string $value
140
- * @return void
140
+ * @return false|null
141 141
  */
142 142
   function setCalscale( $value ) {
143 143
     if( empty( $value )) return FALSE;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
  * @author Kjell-Inge Gustafsson <[email protected]>
274 274
  * @since 2.4.8 - 2008-10-23
275 275
  * @param string $value
276
- * @return void
276
+ * @return boolean
277 277
  */
278 278
   function setVersion( $value ) {
279 279
     if( empty( $value )) return FALSE;
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
  * @since 2.5.1 - 2008-11-02
398 398
  * @param string $propName, optional
399 399
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
400
- * @param bool $inclParam=FALSE
400
+ * @param bool $inclParam
401 401
  * @return mixed
402 402
  */
403 403
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
@@ -448,9 +448,6 @@  discard block
 block discarded – undo
448 448
  *
449 449
  * @author Kjell-Inge Gustafsson <[email protected]>
450 450
  * @since 2.2.13 - 2007-11-04
451
- * @param mixed $args variable number of function arguments,
452
- *                    first argument is ALWAYS component name,
453
- *                    second ALWAYS component value!
454 451
  * @return bool
455 452
  */
456 453
   function setProperty () {
@@ -480,7 +477,7 @@  discard block
 block discarded – undo
480 477
  * @author Kjell-Inge Gustafsson <[email protected]>
481 478
  * @since 2.4.10 - 2008-10-23
482 479
  * @param string $config
483
- * @return value
480
+ * @return string
484 481
  */
485 482
   function getConfig( $config ) {
486 483
     switch( strtoupper( $config )) {
@@ -701,7 +698,7 @@  discard block
 block discarded – undo
701 698
  * @since 2.4.10 - 2008-08-05
702 699
  * @param mixed $arg1 ordno / component type / component uid
703 700
  * @param mixed $arg2 optional, ordno if arg1 = component type
704
- * @return void
701
+ * @return boolean
705 702
  */
706 703
   function deleteComponent( $arg1, $arg2=FALSE  ) {
707 704
     $argType = $index = null;
@@ -1060,7 +1057,7 @@  discard block
 block discarded – undo
1060 1057
  * @param object $component calendar component
1061 1058
  * @param mixed $arg1 optional, ordno/component type/ component uid
1062 1059
  * @param mixed $arg2 optional, ordno if arg1 = component type
1063
- * @return void
1060
+ * @return boolean
1064 1061
  */
1065 1062
   function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066 1063
     if( '' >= $component->getConfig( 'language'))
@@ -2309,7 +2306,7 @@  discard block
 block discarded – undo
2309 2306
  * @param int $min optional
2310 2307
  * @param int $sec optional
2311 2308
  * @param array $params optional
2312
- * @return TRUE
2309
+ * @return boolean
2313 2310
  */
2314 2311
   function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315 2312
     if( empty( $year ))
@@ -2792,7 +2789,7 @@  discard block
 block discarded – undo
2792 2789
  * @param int $min optional
2793 2790
  * @param int $sec optional
2794 2791
  * @param array $params optional
2795
- * @return boll
2792
+ * @return boolean
2796 2793
  */
2797 2794
   function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798 2795
     if( empty( $year ))
@@ -3213,7 +3210,6 @@  discard block
 block discarded – undo
3213 3210
  *
3214 3211
  * @author Kjell-Inge Gustafsson <[email protected]>
3215 3212
  * @since 2.5.1 - 2008-11-07
3216
- * @param float $relid
3217 3213
  * @param array $params, optional
3218 3214
  * @param index $index, optional
3219 3215
  * @return bool
@@ -3251,7 +3247,7 @@  discard block
 block discarded – undo
3251 3247
  * @since 2.4.8 - 2008-11-04
3252 3248
  * @param string $value
3253 3249
  * @param array $params optional
3254
- * @return void
3250
+ * @return boolean
3255 3251
  */
3256 3252
   function setRepeat( $value, $params=FALSE ) {
3257 3253
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
@@ -3374,7 +3370,7 @@  discard block
 block discarded – undo
3374 3370
  * @param array $rruleset
3375 3371
  * @param array $params, optional
3376 3372
  * @param integer $index, optional
3377
- * @return void
3373
+ * @return boolean
3378 3374
  */
3379 3375
   function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380 3376
     if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
@@ -3800,7 +3796,7 @@  discard block
 block discarded – undo
3800 3796
  * @since 2.4.8 - 2008-11-04
3801 3797
  * @param string $value
3802 3798
  * @param string $params optional
3803
- * @return boll
3799
+ * @return boolean
3804 3800
  */
3805 3801
   function setTzurl( $value, $params=FALSE ) {
3806 3802
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
@@ -3929,7 +3925,7 @@  discard block
 block discarded – undo
3929 3925
  * @param string $label
3930 3926
  * @param mixed $value
3931 3927
  * @param array $params optional
3932
- * @return bool
3928
+ * @return null|boolean
3933 3929
  */
3934 3930
   function setXprop( $label, $value, $params=FALSE ) {
3935 3931
     if( empty( $label )) return;
@@ -4096,7 +4092,7 @@  discard block
 block discarded – undo
4096 4092
  * @author Kjell-Inge Gustafsson <[email protected]>
4097 4093
  * @since 0.9.22 - 2007-04-10
4098 4094
  * @param array $params  optional
4099
- * @param array $ctrKeys optional
4095
+ * @param string[] $ctrKeys optional
4100 4096
  * @return string
4101 4097
  */
4102 4098
   function _createParams( $params=array(), $ctrKeys=array() ) {
@@ -4138,7 +4134,6 @@  discard block
 block discarded – undo
4138 4134
  *
4139 4135
  * @author Kjell-Inge Gustafsson <[email protected]>
4140 4136
  * @since 2.4.16 - 2008-10-25
4141
- * @param array $date, date to check
4142 4137
  * @param int $parno, no of date parts (i.e. year, month.. .)
4143 4138
  * @return array $params, property parameters
4144 4139
  */
@@ -4194,7 +4189,6 @@  discard block
 block discarded – undo
4194 4189
  * @author Kjell-Inge Gustafsson <[email protected]>
4195 4190
  * @since 2.2.11 - 2007-11-03
4196 4191
  * @param array $startdate, optional
4197
- * @param array $duration, optional
4198 4192
  * @return array duration
4199 4193
  */
4200 4194
   function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
@@ -4228,7 +4222,7 @@  discard block
 block discarded – undo
4228 4222
  * @since 2.4.8 - 2008-10-30
4229 4223
  * @param array  $datetime  datetime/(date)
4230 4224
  * @param string $tz        timezone
4231
- * @return timestamp
4225
+ * @return integer
4232 4226
  */
4233 4227
   function _date2timestamp( $datetime, $tz=null ) {
4234 4228
     $output = null;
@@ -4541,6 +4535,7 @@  discard block
 block discarded – undo
4541 4535
  * @param int $hitVal optional, return value if found
4542 4536
  * @param int $elseVal optional, return value if not found
4543 4537
  * @param int $preSet optional, return value if already preset
4538
+ * @param string $expkey
4544 4539
  * @return int
4545 4540
  */
4546 4541
   function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
@@ -4650,7 +4645,7 @@  discard block
 block discarded – undo
4650 4645
  *
4651 4646
  * @author Kjell-Inge Gustafsson <[email protected]>
4652 4647
  * @since 2.4.8 - 2008-10-22
4653
- * @param array $recurlabel
4648
+ * @param string $recurlabel
4654 4649
  * @param array $recurdata
4655 4650
  * @return string
4656 4651
  */
@@ -5196,6 +5191,10 @@  discard block
 block discarded – undo
5196 5191
     else
5197 5192
       return FALSE;
5198 5193
   }
5194
+
5195
+  /**
5196
+   * @param integer $wkst
5197
+   */
5199 5198
   function _recurIntervalIx( $freq, $date, $wkst ) {
5200 5199
             /* create interval index */
5201 5200
     switch( $freq ) {
@@ -5504,7 +5503,6 @@  discard block
 block discarded – undo
5504 5503
  *
5505 5504
  * @author Kjell-Inge Gustafsson <[email protected]>
5506 5505
  * @since 2.4.16 - 2008-10-19
5507
- * @param string $offset
5508 5506
  * @return integer
5509 5507
  */
5510 5508
   function _tz2offset( $tz ) {
@@ -5966,8 +5964,8 @@  discard block
 block discarded – undo
5966 5964
  * @since 2.5.1 - 2008-11-02
5967 5965
  * @param string $propName, optional
5968 5966
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5969
- * @param bool $inclParam=FALSE
5970
- * @param bool $specform=FALSE
5967
+ * @param bool $inclParam
5968
+ * @param bool $specform
5971 5969
  * @return mixed
5972 5970
  */
5973 5971
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
@@ -6160,9 +6158,6 @@  discard block
 block discarded – undo
6160 6158
  *
6161 6159
  * @author Kjell-Inge Gustafsson <[email protected]>
6162 6160
  * @since 2.5.1 - 2008-11-05
6163
- * @param mixed $args variable number of function arguments,
6164
- *                    first argument is ALWAYS component name,
6165
- *                    second ALWAYS component value!
6166 6161
  * @return void
6167 6162
  */
6168 6163
   function setProperty() {
@@ -6276,7 +6271,7 @@  discard block
 block discarded – undo
6276 6271
  * @author Kjell-Inge Gustafsson <[email protected]>
6277 6272
  * @since 2.5.2 - 2008-10-23
6278 6273
  * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of property strings
6279
- * @return bool FALSE if error occurs during parsing
6274
+ * @return boolean|null FALSE if error occurs during parsing
6280 6275
  *
6281 6276
  */
6282 6277
   function parse( $unparsedtext=null ) {
@@ -6578,7 +6573,7 @@  discard block
 block discarded – undo
6578 6573
  * @since 2.5.1 - 2008-10-15
6579 6574
  * @param mixed $arg1 ordno / component type / component uid
6580 6575
  * @param mixed $arg2 optional, ordno if arg1 = component type
6581
- * @return void
6576
+ * @return boolean
6582 6577
  */
6583 6578
   function deleteComponent( $arg1, $arg2=FALSE  ) {
6584 6579
     if( !isset( $this->components )) return FALSE;
@@ -6781,7 +6776,7 @@  discard block
 block discarded – undo
6781 6776
  *
6782 6777
  * @author Kjell-Inge Gustafsson <[email protected]>
6783 6778
  * @since 2.2.8 - 2006-09-03
6784
- * @param string $value
6779
+ * @param string $string
6785 6780
  * @return string
6786 6781
  */
6787 6782
   function _size75( $string ) {
Please login to merge, or discard this patch.
Spacing   +2505 added lines, -2505 removed lines patch added patch discarded remove patch
@@ -44,10 +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() )) {
48
-  date_default_timezone_set( 'Europe/Stockholm' );
47
+if (substr(phpversion(), 0, 1) >= '5') // && ( 'UTC' == date_default_timezone_get() )) {
48
+  date_default_timezone_set('Europe/Stockholm');
49 49
             /* version string, do NOT remove!! */
50
-define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' );
50
+define('ICALCREATOR_VERSION', 'iCalcreator 2.6');
51 51
 /*********************************************************************************/
52 52
 /*********************************************************************************/
53 53
 /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
  * @since 2.2.13 - 2007-12-30
88 88
  * @return void
89 89
  */
90
-  function vcalendar () {
90
+  function vcalendar() {
91 91
     $this->_makeVersion();
92 92
     $this->calscale   = null;
93 93
     $this->method     = null;
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 /**
98 98
  *   language = <Text identifying a language, as defined in [RFC 1766]>
99 99
  */
100
-    if( defined( 'ICAL_LANG' ))
101
-      $this->setConfig( 'language', ICAL_LANG );
102
-    $this->setConfig( 'allowEmpty', TRUE );
103
-    $this->setConfig( 'nl',         "\n" );
104
-    $this->setConfig( 'format',     'iCal');
100
+    if (defined('ICAL_LANG'))
101
+      $this->setConfig('language', ICAL_LANG);
102
+    $this->setConfig('allowEmpty', TRUE);
103
+    $this->setConfig('nl', "\n");
104
+    $this->setConfig('format', 'iCal');
105 105
     $this->directory  = null;
106 106
     $this->filename   = null;
107 107
     $this->url        = null;
108
-    $this->setConfig( 'delimiter',  DIRECTORY_SEPARATOR );
108
+    $this->setConfig('delimiter', DIRECTORY_SEPARATOR);
109 109
     $this->xcaldecl   = array();
110 110
     $this->components = array();
111 111
   }
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
  * @return string
122 122
  */
123 123
   function createCalscale() {
124
-    if( empty( $this->calscale )) return FALSE;
125
-    switch( $this->format ) {
124
+    if (empty($this->calscale)) return FALSE;
125
+    switch ($this->format) {
126 126
       case 'xcal':
127 127
         return ' calscale="'.$this->calscale.'"'.$this->nl;
128 128
         break;
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $value
140 140
  * @return void
141 141
  */
142
-  function setCalscale( $value ) {
143
-    if( empty( $value )) return FALSE;
142
+  function setCalscale($value) {
143
+    if (empty($value)) return FALSE;
144 144
     $this->calscale = $value;
145 145
   }
146 146
 /*********************************************************************************/
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
  * @return string
156 156
  */
157 157
   function createMethod() {
158
-    if( empty( $this->method )) return FALSE;
159
-    switch( $this->format ) {
158
+    if (empty($this->method)) return FALSE;
159
+    switch ($this->format) {
160 160
       case 'xcal':
161 161
         return ' method="'.$this->method.'"'.$this->nl;
162 162
         break;
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
  * @param string $value
174 174
  * @return bool
175 175
  */
176
-  function setMethod( $value ) {
177
-    if( empty( $value )) return FALSE;
176
+  function setMethod($value) {
177
+    if (empty($value)) return FALSE;
178 178
     $this->method = $value;
179 179
     return TRUE;
180 180
   }
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
  * @return string
195 195
  */
196 196
   function createProdid() {
197
-    if( !isset( $this->prodid ))
197
+    if (!isset($this->prodid))
198 198
       $this->_makeProdid();
199
-    switch( $this->format ) {
199
+    switch ($this->format) {
200 200
       case 'xcal':
201 201
         return ' prodid="'.$this->prodid.'"'.$this->nl;
202 202
         break;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
  * @return void
214 214
  */
215 215
   function _makeProdid() {
216
-    $this->prodid  = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language );
216
+    $this->prodid = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper($this->language);
217 217
   }
218 218
 /**
219 219
  * Conformance: The property MUST be specified once in an iCalendar object.
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  * @return void
230 230
  */
231 231
   function _makeUnique_id() {
232
-    $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
232
+    $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost';
233 233
   }
234 234
 /*********************************************************************************/
235 235
 /**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
  * @return string
247 247
  */
248 248
   function createVersion() {
249
-    if( empty( $this->version ))
249
+    if (empty($this->version))
250 250
       $this->_makeVersion();
251
-    switch( $this->format ) {
251
+    switch ($this->format) {
252 252
       case 'xcal':
253 253
         return ' version="'.$this->version.'"'.$this->nl;
254 254
         break;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
  * @param string $value
276 276
  * @return void
277 277
  */
278
-  function setVersion( $value ) {
279
-    if( empty( $value )) return FALSE;
278
+  function setVersion($value) {
279
+    if (empty($value)) return FALSE;
280 280
     $this->version = $value;
281 281
     return TRUE;
282 282
   }
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
  * @return string
293 293
  */
294 294
   function createXprop() {
295
-    if( 'xcal' == $this->format )
295
+    if ('xcal' == $this->format)
296 296
       return false;
297
-    if( 0 >= count( $this->xprop ))
297
+    if (0 >= count($this->xprop))
298 298
       return;
299 299
     $output = null;
300 300
     $toolbox = new calendarComponent();
301
-    $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
302
-    $toolbox->setConfig( 'nl',       $this->getConfig( 'nl' ));
303
-    $toolbox->_createFormat(         $this->getConfig( 'format' ));
304
-    foreach( $this->xprop as $label => $xpropPart ) {
305
-      if( empty( $xpropPart['value'] )) {
306
-        $output  .= $toolbox->_createElement( $label );
301
+    $toolbox->setConfig('language', $this->getConfig('language'));
302
+    $toolbox->setConfig('nl', $this->getConfig('nl'));
303
+    $toolbox->_createFormat($this->getConfig('format'));
304
+    foreach ($this->xprop as $label => $xpropPart) {
305
+      if (empty($xpropPart['value'])) {
306
+        $output  .= $toolbox->_createElement($label);
307 307
         continue;
308 308
       }
309
-      $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
310
-      if( is_array( $xpropPart['value'] )) {
311
-        foreach( $xpropPart['value'] as $pix => $theXpart )
312
-          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
313
-        $xpropPart['value']  = implode( ',', $xpropPart['value'] );
309
+      $attributes = $toolbox->_createParams($xpropPart['params'], array('LANGUAGE'));
310
+      if (is_array($xpropPart['value'])) {
311
+        foreach ($xpropPart['value'] as $pix => $theXpart)
312
+          $xpropPart['value'][$pix] = $toolbox->_strrep($theXpart);
313
+        $xpropPart['value'] = implode(',', $xpropPart['value']);
314 314
       }
315 315
       else
316
-        $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
317
-      $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
316
+        $xpropPart['value'] = $toolbox->_strrep($xpropPart['value']);
317
+      $output .= $toolbox->_createElement($label, $attributes, $xpropPart['value']);
318 318
     }
319 319
     return $output;
320 320
   }
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
  * @param array $params optional
329 329
  * @return bool
330 330
  */
331
-  function setXprop( $label, $value, $params=FALSE ) {
332
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
333
-    if( empty( $label )) return FALSE;
334
-    $xprop           = array( 'value' => $value );
331
+  function setXprop($label, $value, $params = FALSE) {
332
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
333
+    if (empty($label)) return FALSE;
334
+    $xprop           = array('value' => $value);
335 335
     $toolbox         = new calendarComponent();
336
-    $xprop['params'] = $toolbox->_setParams( $params );
337
-    if( !is_array( $this->xprop )) $this->xprop = array();
338
-    $this->xprop[strtoupper( $label )] = $xprop;
336
+    $xprop['params'] = $toolbox->_setParams($params);
337
+    if (!is_array($this->xprop)) $this->xprop = array();
338
+    $this->xprop[strtoupper($label)] = $xprop;
339 339
     return TRUE;
340 340
   }
341 341
 /*********************************************************************************/
@@ -348,39 +348,39 @@  discard block
 block discarded – undo
348 348
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
349 349
  * @return bool, if successfull delete
350 350
  */
351
-  function deleteProperty( $propName, $propix=FALSE ) {
352
-    $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
353
-    if( !$propix )
354
-      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
351
+  function deleteProperty($propName, $propix = FALSE) {
352
+    $propName = ($propName) ? strtoupper($propName) : 'X-PROP';
353
+    if (!$propix)
354
+      $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1;
355 355
     $this->propdelix[$propName] = --$propix;
356 356
     $return = FALSE;
357
-    switch( $propName ) {
357
+    switch ($propName) {
358 358
       case 'CALSCALE':
359
-        if( isset( $this->calscale )) {
359
+        if (isset($this->calscale)) {
360 360
           $this->calscale = null;
361 361
           $return = TRUE;
362 362
         }
363 363
         break;
364 364
       case 'METHOD':
365
-        if( isset( $this->method )) {
366
-          $this->method   = null;
365
+        if (isset($this->method)) {
366
+          $this->method = null;
367 367
           $return = TRUE;
368 368
         }
369 369
         break;
370 370
       default:
371 371
         $reduced = array();
372
-        if( $propName != 'X-PROP' ) {
373
-          if( !isset( $this->xprop[$propName] )) return FALSE;
374
-          foreach( $this->xprop as $k => $a ) {
375
-            if(( $k != $propName ) && !empty( $a ))
372
+        if ($propName != 'X-PROP') {
373
+          if (!isset($this->xprop[$propName])) return FALSE;
374
+          foreach ($this->xprop as $k => $a) {
375
+            if (($k != $propName) && !empty($a))
376 376
               $reduced[$k] = $a;
377 377
           }
378 378
         }
379 379
         else {
380
-          if( count( $this->xprop ) <= $propix )  return FALSE;
380
+          if (count($this->xprop) <= $propix)  return FALSE;
381 381
           $xpropno = 0;
382
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
383
-            if( $propix != $xpropno )
382
+          foreach ($this->xprop as $xpropkey => $xpropvalue) {
383
+            if ($propix != $xpropno)
384 384
               $reduced[$xpropkey] = $xpropvalue;
385 385
             $xpropno++;
386 386
           }
@@ -400,41 +400,41 @@  discard block
 block discarded – undo
400 400
  * @param bool $inclParam=FALSE
401 401
  * @return mixed
402 402
  */
403
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
404
-    $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
405
-    if( 'X-PROP' == $propName ) {
406
-      if( !$propix )
407
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
403
+  function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE) {
404
+    $propName = ($propName) ? strtoupper($propName) : 'X-PROP';
405
+    if ('X-PROP' == $propName) {
406
+      if (!$propix)
407
+        $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1;
408 408
       $this->propix[$propName] = --$propix;
409 409
     }
410
-    switch( $propName ) {
410
+    switch ($propName) {
411 411
       case 'CALSCALE':
412
-        return ( !empty( $this->calscale )) ? $this->calscale : null;
412
+        return (!empty($this->calscale)) ? $this->calscale : null;
413 413
         break;
414 414
       case 'METHOD':
415
-        return ( !empty( $this->method )) ? $this->method : null;
415
+        return (!empty($this->method)) ? $this->method : null;
416 416
         break;
417 417
       case 'PRODID':
418
-        if( empty( $this->prodid ))
418
+        if (empty($this->prodid))
419 419
           $this->_makeProdid();
420 420
         return $this->prodid;
421 421
         break;
422 422
       case 'VERSION':
423
-        return ( !empty( $this->version )) ? $this->version : null;
423
+        return (!empty($this->version)) ? $this->version : null;
424 424
         break;
425 425
       default:
426
-        if( $propName != 'X-PROP' ) {
427
-          if( !isset( $this->xprop[$propName] )) return FALSE;
428
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
429
-                                : array( $propName, $this->xprop[$propName]['value'] );
426
+        if ($propName != 'X-PROP') {
427
+          if (!isset($this->xprop[$propName])) return FALSE;
428
+          return ($inclParam) ? array($propName, $this->xprop[$propName])
429
+                                : array($propName, $this->xprop[$propName]['value']);
430 430
         }
431 431
         else {
432
-          if( empty( $this->xprop )) return FALSE;
432
+          if (empty($this->xprop)) return FALSE;
433 433
           $xpropno = 0;
434
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
435
-            if( $propix == $xpropno )
436
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
437
-                                    : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
434
+          foreach ($this->xprop as $xpropkey => $xpropvalue) {
435
+            if ($propix == $xpropno)
436
+              return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey])
437
+                                    : array($xpropkey, $this->xprop[$xpropkey]['value']);
438 438
             else
439 439
               $xpropno++;
440 440
           }
@@ -453,23 +453,23 @@  discard block
 block discarded – undo
453 453
  *                    second ALWAYS component value!
454 454
  * @return bool
455 455
  */
456
-  function setProperty () {
456
+  function setProperty() {
457 457
     $numargs    = func_num_args();
458
-    if( 1 > $numargs )
458
+    if (1 > $numargs)
459 459
       return FALSE;
460 460
     $arglist    = func_get_args();
461
-    $arglist[0] = strtoupper( $arglist[0] );
462
-    switch( $arglist[0] ) {
461
+    $arglist[0] = strtoupper($arglist[0]);
462
+    switch ($arglist[0]) {
463 463
       case 'CALSCALE':
464
-        return $this->setCalscale( $arglist[1] );
464
+        return $this->setCalscale($arglist[1]);
465 465
       case 'METHOD':
466
-        return $this->setMethod( $arglist[1] );
466
+        return $this->setMethod($arglist[1]);
467 467
       case 'VERSION':
468
-        return $this->setVersion( $arglist[1] );
468
+        return $this->setVersion($arglist[1]);
469 469
       default:
470
-        if( !isset( $arglist[1] )) $arglist[1] = null;
471
-        if( !isset( $arglist[2] )) $arglist[2] = null;
472
-        return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
470
+        if (!isset($arglist[1])) $arglist[1] = null;
471
+        if (!isset($arglist[2])) $arglist[2] = null;
472
+        return $this->setXprop($arglist[0], $arglist[1], $arglist[2]);
473 473
     }
474 474
     return FALSE;
475 475
   }
@@ -482,23 +482,23 @@  discard block
 block discarded – undo
482 482
  * @param string $config
483 483
  * @return value
484 484
  */
485
-  function getConfig( $config ) {
486
-    switch( strtoupper( $config )) {
485
+  function getConfig($config) {
486
+    switch (strtoupper($config)) {
487 487
       case 'ALLOWEMPTY':
488 488
         return $this->allowEmpty;
489 489
         break;
490 490
       case 'COMPSINFO':
491
-        unset( $this->compix );
491
+        unset($this->compix);
492 492
         $info = array();
493
-        foreach( $this->components as $cix => $component ) {
494
-          if( empty( $component )) continue;
495
-          unset( $component->propix );
493
+        foreach ($this->components as $cix => $component) {
494
+          if (empty($component)) continue;
495
+          unset($component->propix);
496 496
           $info[$cix]['ordno'] = $cix + 1;
497 497
           $info[$cix]['type']  = $component->objName;
498
-          $info[$cix]['uid']   = $component->getProperty( 'uid' );
499
-          $info[$cix]['props'] = $component->getConfig( 'propinfo' );
500
-          $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
501
-          unset( $component->propix );
498
+          $info[$cix]['uid']   = $component->getProperty('uid');
499
+          $info[$cix]['props'] = $component->getConfig('propinfo');
500
+          $info[$cix]['sub']   = $component->getConfig('compsinfo');
501
+          unset($component->propix);
502 502
         }
503 503
         return $info;
504 504
         break;
@@ -506,32 +506,32 @@  discard block
 block discarded – undo
506 506
         return $this->delimiter;
507 507
         break;
508 508
       case 'DIRECTORY':
509
-        if( empty( $this->directory ))
509
+        if (empty($this->directory))
510 510
           $this->directory = '.';
511 511
         return $this->directory;
512 512
         break;
513 513
       case 'DIRFILE':
514
-        return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' );
514
+        return $this->getConfig('directory').$this->getConfig('delimiter').$this->getConfig('filename');
515 515
         break;
516 516
       case 'FILEINFO':
517
-        return array( $this->getConfig( 'directory' )
518
-                    , $this->getConfig( 'filename' )
519
-                    , $this->getConfig( 'filesize' ));
517
+        return array($this->getConfig('directory')
518
+                    , $this->getConfig('filename')
519
+                    , $this->getConfig('filesize'));
520 520
         break;
521 521
       case 'FILENAME':
522
-        if( empty( $this->filename )) {
523
-          if( 'xcal' == $this->format )
524
-            $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
522
+        if (empty($this->filename)) {
523
+          if ('xcal' == $this->format)
524
+            $this->filename = date('YmdHis').'.xml'; // recommended xcs.. .
525 525
           else
526
-            $this->filename = date( 'YmdHis' ).'.ics';
526
+            $this->filename = date('YmdHis').'.ics';
527 527
         }
528 528
         return $this->filename;
529 529
         break;
530 530
       case 'FILESIZE':
531
-        $size    = 0;
532
-        if( empty( $this->url )) {
533
-          $dirfile = $this->getConfig( 'dirfile' );
534
-          if( FALSE === ( $size = filesize( $dirfile )))
531
+        $size = 0;
532
+        if (empty($this->url)) {
533
+          $dirfile = $this->getConfig('dirfile');
534
+          if (FALSE === ($size = filesize($dirfile)))
535 535
             $size = 0;
536 536
           clearstatcache();
537 537
         }
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
         return $this->unique_id;
553 553
         break;
554 554
       case 'URL':
555
-        if( !empty( $this->url ))
555
+        if (!empty($this->url))
556 556
           return $this->url;
557 557
         else
558 558
           return FALSE;
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
  * @param string $value
569 569
  * @return void
570 570
  */
571
-  function setConfig( $config, $value ) {
571
+  function setConfig($config, $value) {
572 572
     $res = FALSE;
573
-    switch( strtoupper( $config )) {
573
+    switch (strtoupper($config)) {
574 574
       case 'ALLOWEMPTY':
575 575
         $this->allowEmpty = $value;
576
-        $subcfg  = array( 'ALLOWEMPTY' => $value );
576
+        $subcfg = array('ALLOWEMPTY' => $value);
577 577
         $res = TRUE;
578 578
         break;
579 579
       case 'DELIMITER':
@@ -581,11 +581,11 @@  discard block
 block discarded – undo
581 581
         return TRUE;
582 582
         break;
583 583
       case 'DIRECTORY':
584
-        $value   = trim( $value );
584
+        $value   = trim($value);
585 585
         $nl      = $this->getConfig('delimiter');
586
-        if( $nl == substr( $value, ( 0 - strlen( $nl ))))
587
-          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
588
-        if( is_dir( $value )) {
586
+        if ($nl == substr($value, (0 - strlen($nl))))
587
+          $value = substr($value, 0, (strlen($value) - strlen($nl)));
588
+        if (is_dir($value)) {
589 589
             /* local directory */
590 590
           clearstatcache();
591 591
           $this->directory = $value;
@@ -596,16 +596,16 @@  discard block
 block discarded – undo
596 596
           return FALSE;
597 597
         break;
598 598
       case 'FILENAME':
599
-        $value   = trim( $value );
600
-        if( !empty( $this->url )) {
599
+        $value = trim($value);
600
+        if (!empty($this->url)) {
601 601
             /* remote directory+file - URL */
602 602
           $this->filename = $value;
603 603
           return TRUE;
604 604
         }
605
-        $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value;
606
-        if( file_exists( $dirfile )) {
605
+        $dirfile = $this->getConfig('directory').$this->getConfig('delimiter').$value;
606
+        if (file_exists($dirfile)) {
607 607
             /* local existing file */
608
-          if( is_readable( $dirfile ) || is_writable( $dirfile )) {
608
+          if (is_readable($dirfile) || is_writable($dirfile)) {
609 609
             clearstatcache();
610 610
             $this->filename = $value;
611 611
             return TRUE;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
           else
614 614
             return FALSE;
615 615
         }
616
-        elseif( FALSE !== touch( $dirfile )) {
616
+        elseif (FALSE !== touch($dirfile)) {
617 617
             /* new local file created */
618 618
           $this->filename = $value;
619 619
           return TRUE;
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
           return FALSE;
623 623
         break;
624 624
       case 'FORMAT':
625
-        $value   = trim( $value );
626
-        if( 'xcal' == strtolower( $value )) {
625
+        $value = trim($value);
626
+        if ('xcal' == strtolower($value)) {
627 627
           $this->format             = 'xcal';
628 628
           $this->attributeDelimiter = $this->nl;
629 629
           $this->valueInit          = null;
@@ -633,46 +633,46 @@  discard block
 block discarded – undo
633 633
           $this->attributeDelimiter = ';';
634 634
           $this->valueInit          = ':';
635 635
         }
636
-        $subcfg  = array( 'FORMAT' => $value );
636
+        $subcfg = array('FORMAT' => $value);
637 637
         $res = TRUE;
638 638
         break;
639 639
       case 'LANGUAGE':
640 640
          // set language for calendar component as defined in [RFC 1766]
641
-        $value   = trim( $value );
641
+        $value   = trim($value);
642 642
         $this->language = $value;
643
-        $subcfg  = array( 'LANGUAGE' => $value );
643
+        $subcfg  = array('LANGUAGE' => $value);
644 644
         $res = TRUE;
645 645
         break;
646 646
       case 'NL':
647 647
       case 'NEWLINECHAR':
648 648
         $this->nl = $value;
649
-        $subcfg  = array( 'NL' => $value );
649
+        $subcfg = array('NL' => $value);
650 650
         $res = TRUE;
651 651
         break;
652 652
       case 'UNIQUE_ID':
653
-        $value   = trim( $value );
653
+        $value   = trim($value);
654 654
         $this->unique_id = $value;
655
-        $subcfg  = array( 'UNIQUE_ID' => $value );
655
+        $subcfg  = array('UNIQUE_ID' => $value);
656 656
         $res = TRUE;
657 657
         break;
658 658
       case 'URL':
659 659
             /* remote file - URL */
660
-        $value     = trim( $value );
661
-        $value     = str_replace( 'HTTP://',   'http://', $value );
662
-        $value     = str_replace( 'WEBCAL://', 'http://', $value );
663
-        $value     = str_replace( 'webcal://', 'http://', $value );
660
+        $value     = trim($value);
661
+        $value     = str_replace('HTTP://', 'http://', $value);
662
+        $value     = str_replace('WEBCAL://', 'http://', $value);
663
+        $value     = str_replace('webcal://', 'http://', $value);
664 664
         $this->url = $value;
665 665
         $this->directory = null;
666
-        $parts     = pathinfo( $value );
667
-        return $this->setConfig( 'filename',  $parts['basename'] );
666
+        $parts     = pathinfo($value);
667
+        return $this->setConfig('filename', $parts['basename']);
668 668
         break;
669 669
     }
670
-    if( !$res ) return FALSE;
671
-    if( isset( $subcfg ) && !empty( $this->components )) {
672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
673
-        foreach( $this->components as $cix => $component ) {
674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
675
-          if( !$res )
670
+    if (!$res) return FALSE;
671
+    if (isset($subcfg) && !empty($this->components)) {
672
+      foreach ($subcfg as $cfgkey => $cfgvalue) {
673
+        foreach ($this->components as $cix => $component) {
674
+          $res = $component->setConfig($cfgkey, $cfgvalue);
675
+          if (!$res)
676 676
             break 2;
677 677
           $this->components[$cix] = $component->copy(); // PHP4 compliant
678 678
         }
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
  * @param object $component calendar component
692 692
  * @return void
693 693
  */
694
-  function addComponent( $component ) {
695
-    $this->setComponent( $component );
694
+  function addComponent($component) {
695
+    $this->setComponent($component);
696 696
   }
697 697
 /**
698 698
  * delete calendar component from container
@@ -703,33 +703,33 @@  discard block
 block discarded – undo
703 703
  * @param mixed $arg2 optional, ordno if arg1 = component type
704 704
  * @return void
705 705
  */
706
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
706
+  function deleteComponent($arg1, $arg2 = FALSE) {
707 707
     $argType = $index = null;
708
-    if ( ctype_digit( (string) $arg1 )) {
708
+    if (ctype_digit((string) $arg1)) {
709 709
       $argType = 'INDEX';
710 710
       $index   = (int) $arg1 - 1;
711 711
     }
712
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
713
-      $argType = strtolower( $arg1 );
714
-      $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
712
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
713
+      $argType = strtolower($arg1);
714
+      $index   = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0;
715 715
     }
716 716
     $cix1dC = 0;
717
-    foreach ( $this->components as $cix => $component) {
718
-      if( empty( $component )) continue;
719
-      unset( $component->propix );
720
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721
-        unset( $this->components[$cix] );
717
+    foreach ($this->components as $cix => $component) {
718
+      if (empty($component)) continue;
719
+      unset($component->propix);
720
+      if (('INDEX' == $argType) && ($index == $cix)) {
721
+        unset($this->components[$cix]);
722 722
         return TRUE;
723 723
       }
724
-      elseif( $argType == $component->objName ) {
725
-        if( $index == $cix1dC ) {
726
-          unset( $this->components[$cix] );
724
+      elseif ($argType == $component->objName) {
725
+        if ($index == $cix1dC) {
726
+          unset($this->components[$cix]);
727 727
           return TRUE;
728 728
         }
729 729
         $cix1dC++;
730 730
       }
731
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732
-        unset( $this->components[$cix] );
731
+      elseif (!$argType && ($arg1 == $component->getProperty('uid'))) {
732
+        unset($this->components[$cix]);
733 733
         return TRUE;
734 734
       }
735 735
     }
@@ -744,49 +744,49 @@  discard block
 block discarded – undo
744 744
  * @param mixed $arg2 optional, ordno if arg1 = component type
745 745
  * @return object
746 746
  */
747
-  function getComponent( $arg1=FALSE, $arg2=FALSE ) {
747
+  function getComponent($arg1 = FALSE, $arg2 = FALSE) {
748 748
     $index = $argType = null;
749
-    if ( !$arg1 ) {
749
+    if (!$arg1) {
750 750
       $argType = 'INDEX';
751 751
       $index   = $this->compix['INDEX'] =
752
-        ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
752
+        (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1;
753 753
     }
754
-    elseif ( ctype_digit( (string) $arg1 )) {
754
+    elseif (ctype_digit((string) $arg1)) {
755 755
       $argType = 'INDEX';
756 756
       $index   = (int) $arg1;
757
-      unset( $this->compix );
757
+      unset($this->compix);
758 758
     }
759
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
760
-      unset( $this->compix['INDEX'] );
761
-      $argType = strtolower( $arg1 );
762
-      if( !$arg2 )
759
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
760
+      unset($this->compix['INDEX']);
761
+      $argType = strtolower($arg1);
762
+      if (!$arg2)
763 763
         $index = $this->compix[$argType] =
764
-        ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
764
+        (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1;
765 765
       else
766 766
         $index = (int) $arg2;
767 767
     }
768
-    $index  -= 1;
769
-    $ckeys =  array_keys( $this->components );
770
-    if( !empty( $index) && ( $index > end(  $ckeys )))
768
+    $index -= 1;
769
+    $ckeys = array_keys($this->components);
770
+    if (!empty($index) && ($index > end($ckeys)))
771 771
       return FALSE;
772 772
     $cix1gC = 0;
773
-    foreach ( $this->components as $cix => $component) {
774
-      if( empty( $component )) continue;
775
-      unset( $component->propix );
776
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
773
+    foreach ($this->components as $cix => $component) {
774
+      if (empty($component)) continue;
775
+      unset($component->propix);
776
+      if (('INDEX' == $argType) && ($index == $cix))
777 777
         return $component->copy();
778
-      elseif( $argType == $component->objName ) {
779
-         if( $index == $cix1gC )
778
+      elseif ($argType == $component->objName) {
779
+         if ($index == $cix1gC)
780 780
            return $component->copy();
781 781
          $cix1gC++;
782 782
       }
783
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
784
-        unset( $component->propix );
783
+      elseif (!$argType && ($arg1 == $component->getProperty('uid'))) {
784
+        unset($component->propix);
785 785
         return $component->copy();
786 786
       }
787 787
     }
788 788
             /* not found.. . */
789
-    unset( $this->compix );
789
+    unset($this->compix);
790 790
     return FALSE;
791 791
   }
792 792
 /**
@@ -813,242 +813,242 @@  discard block
 block discarded – undo
813 813
  *                               FALSE - one occurance of component only in output array</tr>
814 814
  * @return array or FALSE
815 815
  */
816
-  function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
816
+  function selectComponents($startY = FALSE, $startM = FALSE, $startD = FALSE, $endY = FALSE, $endM = FALSE, $endD = FALSE, $cType = FALSE, $flat = FALSE, $any = TRUE, $split = TRUE) {
817 817
             /* check  if empty calendar */
818
-    if( 0 >= count( $this->components )) return FALSE;
818
+    if (0 >= count($this->components)) return FALSE;
819 819
             /* check default dates */
820
-    if( !$startY ) $startY = date( 'Y' );
821
-    if( !$startM ) $startM = date( 'm' );
822
-    if( !$startD ) $startD = date( 'd' );
823
-    $startDate = mktime( 0, 0, 0, $startM, $startD, $startY );
824
-    if( !$endY )   $endY   = $startY;
825
-    if( !$endM )   $endM   = $startM;
826
-    if( !$endD )   $endD   = $startD;
827
-    $endDate   = mktime( 23, 59, 59, $endM, $endD, $endY );
820
+    if (!$startY) $startY = date('Y');
821
+    if (!$startM) $startM = date('m');
822
+    if (!$startD) $startD = date('d');
823
+    $startDate = mktime(0, 0, 0, $startM, $startD, $startY);
824
+    if (!$endY)   $endY   = $startY;
825
+    if (!$endM)   $endM   = $startM;
826
+    if (!$endD)   $endD   = $startD;
827
+    $endDate = mktime(23, 59, 59, $endM, $endD, $endY);
828 828
             /* check component types */
829
-    $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
830
-    if( is_array( $cType )) {
831
-      foreach( $cType as $cix => $theType ) {
832
-        $cType[$cix] = $theType = strtolower( $theType );
833
-        if( !in_array( $theType, $validTypes ))
829
+    $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy');
830
+    if (is_array($cType)) {
831
+      foreach ($cType as $cix => $theType) {
832
+        $cType[$cix] = $theType = strtolower($theType);
833
+        if (!in_array($theType, $validTypes))
834 834
           $cType[$cix] = 'vevent';
835 835
       }
836
-      $cType = array_unique( $cType );
836
+      $cType = array_unique($cType);
837 837
     }
838
-    elseif( !empty( $cType )) {
839
-      $cType = strtolower( $cType );
840
-      if( !in_array( $cType, $validTypes ))
841
-        $cType = array( 'vevent' );
838
+    elseif (!empty($cType)) {
839
+      $cType = strtolower($cType);
840
+      if (!in_array($cType, $validTypes))
841
+        $cType = array('vevent');
842 842
       else
843
-        $cType = array( $cType );
843
+        $cType = array($cType);
844 844
     }
845 845
     else
846 846
       $cType = $validTypes;
847
-    if( 0 >= count( $cType ))
847
+    if (0 >= count($cType))
848 848
       $cType = $validTypes;
849 849
             /* iterate components */
850 850
     $result = array();
851
-    foreach ( $this->components as $cix => $component ) {
852
-      if( empty( $component )) continue;
853
-      unset( $component->propix, $start );
851
+    foreach ($this->components as $cix => $component) {
852
+      if (empty($component)) continue;
853
+      unset($component->propix, $start);
854 854
             /* deselect unvalid type components */
855
-      if( !in_array( $component->objName, $cType )) continue;
855
+      if (!in_array($component->objName, $cType)) continue;
856 856
             /* deselect components without dtstart set */
857
-      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
857
+      if (FALSE === ($start = $component->getProperty('dtstart'))) continue;
858 858
       $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
859
-      unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
860
-      $startWdate = $component->_date2timestamp( $start );
861
-      $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
859
+      unset($end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend); // clean up
860
+      $startWdate = $component->_date2timestamp($start);
861
+      $startDateFormat = (isset($start['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d';
862 862
             /* get end date from dtend/due/duration properties */
863
-      $end = $component->getProperty( 'dtend' );
864
-      if( !empty( $end )) {
863
+      $end = $component->getProperty('dtend');
864
+      if (!empty($end)) {
865 865
         $dtendExist = TRUE;
866
-        $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
866
+        $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d';
867 867
       }
868 868
    // if( !empty($end))  echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
869
-      if( empty($end) && ( $component->objName == 'vtodo' )) {
870
-        $end = $component->getProperty( 'due' );
871
-        if( !empty( $end )) {
869
+      if (empty($end) && ($component->objName == 'vtodo')) {
870
+        $end = $component->getProperty('due');
871
+        if (!empty($end)) {
872 872
           $dueExist = TRUE;
873
-          $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
873
+          $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d';
874 874
         }
875 875
    // if( !empty($end))  echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
876 876
       }
877
-      if( !empty( $end ) && !isset( $end['hour'] )) {
877
+      if (!empty($end) && !isset($end['hour'])) {
878 878
           /* a DTEND without time part regards an event that ends the day before,
879 879
              for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */
880 880
         $endAllDayEvent = TRUE;
881
-        $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] );
882
-        $end['year']  = date( 'Y', $endWdate );
883
-        $end['month'] = date( 'm', $endWdate );
884
-        $end['day']   = date( 'd', $endWdate );
881
+        $endWdate = mktime(23, 59, 59, $end['month'], ($end['day'] - 1), $end['year']);
882
+        $end['year']  = date('Y', $endWdate);
883
+        $end['month'] = date('m', $endWdate);
884
+        $end['day']   = date('d', $endWdate);
885 885
         $end['hour']  = 23;
886 886
         $end['min']   = $end['sec'] = 59;
887 887
    // if( !empty($end))  echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
888 888
       }
889
-      if( empty( $end )) {
890
-        $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
891
-        if( !empty( $end ))
889
+      if (empty($end)) {
890
+        $end = $component->getProperty('duration', FALSE, FALSE, TRUE); // in dtend (array) format
891
+        if (!empty($end))
892 892
           $durationExist = TRUE;
893 893
    // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
894 894
       }
895
-      if( empty( $end )) { // assume one day duration if missing end date
896
-        $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
895
+      if (empty($end)) { // assume one day duration if missing end date
896
+        $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59);
897 897
    // if( isset($end))  echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
898 898
       }
899
-      $endWdate = $component->_date2timestamp( $end );
900
-      if( $endWdate < $startWdate ) { // MUST be after start date!!
901
-        $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
902
-        $endWdate = $component->_date2timestamp( $end );
899
+      $endWdate = $component->_date2timestamp($end);
900
+      if ($endWdate < $startWdate) { // MUST be after start date!!
901
+        $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59);
902
+        $endWdate = $component->_date2timestamp($end);
903 903
       }
904 904
       $rdurWsecs  = $endWdate - $startWdate; // compute component duration in seconds
905
-      $rdur       = $component->_date2duration( $start, $end ); // compute component duration, array
905
+      $rdur       = $component->_date2duration($start, $end); // compute component duration, array
906 906
             /* make a list of optional exclude dates for component occurence from exrule and exdate */
907 907
       $exdatelist = array();
908
-      $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
909
-      $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
910
-      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
911
-        $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
912
-      while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
913
-        foreach( $exdate as $theExdate ) {
914
-          $exWdate = $component->_date2timestamp( $theExdate );
915
-          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
908
+      $workstart  = $component->_timestamp2date(($startDate - $rdurWsecs), 6);
909
+      $workend    = $component->_timestamp2date(($endDate + $rdurWsecs), 6);
910
+      while (FALSE !== ($exrule = $component->getProperty('exrule')))    // check exrule
911
+        $component->_recur2date($exdatelist, $exrule, $start, $workstart, $workend);
912
+      while (FALSE !== ($exdate = $component->getProperty('exdate'))) {  // check exdate
913
+        foreach ($exdate as $theExdate) {
914
+          $exWdate = $component->_date2timestamp($theExdate);
915
+          if ((($startDate - $rdurWsecs) <= $exWdate) && ($endDate >= $exWdate))
916 916
             $exdatelist[$exWdate] = TRUE;
917 917
         }
918 918
       }
919 919
             /* if 'any' components, check repeating components, removing all excluding dates */
920
-      if( TRUE === $any ) {
920
+      if (TRUE === $any) {
921 921
             /* make a list of optional repeating dates for component occurence, rrule, rdate */
922 922
         $recurlist = array();
923
-        while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
924
-          $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
925
-        foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
923
+        while (FALSE !== ($rrule = $component->getProperty('rrule')))    // check rrule
924
+          $component->_recur2date($recurlist, $rrule, $start, $workstart, $workend);
925
+        foreach ($recurlist as $recurkey => $recurvalue) // key=match date as timestamp
926 926
           $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
927
-        while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
928
-          foreach( $rdate as $theRdate ) {
929
-            if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
930
-                   array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
931
-              $rstart = $component->_date2timestamp( $theRdate[0] );
932
-              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
927
+        while (FALSE !== ($rdate = $component->getProperty('rdate'))) {  // check rdate
928
+          foreach ($rdate as $theRdate) {
929
+            if (is_array($theRdate) && (2 == count($theRdate)) && // all days within PERIOD
930
+                   array_key_exists('0', $theRdate) && array_key_exists('1', $theRdate)) {
931
+              $rstart = $component->_date2timestamp($theRdate[0]);
932
+              if (($rstart < ($startDate - $rdurWsecs)) || ($rstart > $endDate))
933 933
                 continue;
934
-              if( isset( $theRdate[1]['year'] )) // date-date period
935
-                $rend = $component->_date2timestamp( $theRdate[1] );
934
+              if (isset($theRdate[1]['year'])) // date-date period
935
+                $rend = $component->_date2timestamp($theRdate[1]);
936 936
               else {                             // date-duration period
937
-                $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
938
-                $rend = $component->_date2timestamp( $rend );
937
+                $rend = $component->duration2date($theRdate[0], $theRdate[1]);
938
+                $rend = $component->_date2timestamp($rend);
939 939
               }
940
-              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
941
-                $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
940
+              if ((($startDate - $rdurWsecs) <= $rstart) && ($endDate >= $rstart))
941
+                $recurlist[$rstart] = ($rstart - $rend); // set start date + rdate duration in seconds
942 942
             } // PERIOD end
943 943
             else { // single date
944
-              $theRdate = $component->_date2timestamp( $theRdate );
945
-              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
944
+              $theRdate = $component->_date2timestamp($theRdate);
945
+              if ((($startDate - $rdurWsecs) <= $theRdate) && ($endDate >= $theRdate))
946 946
                 $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
947 947
             }
948 948
           }
949 949
         }
950
-        if( 0 < count( $recurlist )) {
951
-          ksort( $recurlist );
952
-          foreach( $recurlist as $recurkey => $durvalue ) {
953
-            if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
950
+        if (0 < count($recurlist)) {
951
+          ksort($recurlist);
952
+          foreach ($recurlist as $recurkey => $durvalue) {
953
+            if ((($startDate - $rdurWsecs) > $recurkey) || ($endDate < $recurkey)) // not within period
954 954
               continue;
955
-            if( isset( $exdatelist[$recurkey] )) // check excluded dates
955
+            if (isset($exdatelist[$recurkey])) // check excluded dates
956 956
               continue;
957
-            if( $startWdate >= $recurkey ) // exclude component start date
957
+            if ($startWdate >= $recurkey) // exclude component start date
958 958
               continue;
959 959
             $component2   = $component->copy();
960
-            $rstart       = $component2->_timestamp2date( $recurkey, 6);
960
+            $rstart       = $component2->_timestamp2date($recurkey, 6);
961 961
             $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
962
-            if( isset( $start['hour'] ) || isset( $start['min'] ) || isset( $start['sec'] )) {
963
-              $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00';
964
-              $datevalue .= ( isset( $rstart['min'] ))  ? ':'.$rstart['min']  : ':00';
965
-              $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
962
+            if (isset($start['hour']) || isset($start['min']) || isset($start['sec'])) {
963
+              $datevalue .= (isset($rstart['hour'])) ? ' '.$rstart['hour'] : ' 00';
964
+              $datevalue .= (isset($rstart['min'])) ? ':'.$rstart['min'] : ':00';
965
+              $datevalue .= (isset($rstart['sec'])) ? ':'.$rstart['sec'] : ':00';
966 966
             }
967
-            $datestring = date( $startDateFormat, strtotime( $datevalue ));
968
-            if( isset( $start['tz'] ))
967
+            $datestring = date($startDateFormat, strtotime($datevalue));
968
+            if (isset($start['tz']))
969 969
               $datestring .= ' '.$start['tz'];
970
-            $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
971
-            $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
972
-            if( $dtendExist || $dueExist ) {
973
-              if( $endAllDayEvent ) {
974
-                $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
975
-                $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
970
+            $component2->setProperty('X-CURRENT-DTSTART', $datestring);
971
+            $rend = $component2->_timestamp2date(($recurkey + $durvalue), 6);
972
+            if ($dtendExist || $dueExist) {
973
+              if ($endAllDayEvent) {
974
+                $rend2 = mktime(0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year']);
975
+                $datevalue  = date('m', $rend2).'/'.date('d', $rend2).'/'.date('Y', $rend2);
976 976
               }
977 977
               else {
978 978
                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
979
-                if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) {
980
-                  $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
981
-                  $datevalue .= ( isset( $rend['min'] ))  ? ':'.$rend['min']  : ':00';
982
-                  $datevalue .= ( isset( $rend['sec'] ))  ? ':'.$rend['sec']  : ':00';
979
+                if (isset($end['hour']) || isset($end['min']) || isset($end['sec'])) {
980
+                  $datevalue .= (isset($rend['hour'])) ? ' '.$rend['hour'] : ' 00';
981
+                  $datevalue .= (isset($rend['min'])) ? ':'.$rend['min'] : ':00';
982
+                  $datevalue .= (isset($rend['sec'])) ? ':'.$rend['sec'] : ':00';
983 983
                 }
984 984
               }
985
-              $datestring = date( $endDateFormat, strtotime( $datevalue ));
986
-              if( isset( $end['tz'] ))
985
+              $datestring = date($endDateFormat, strtotime($datevalue));
986
+              if (isset($end['tz']))
987 987
                 $datestring .= ' '.$end['tz'];
988
-              if( $dtendExist )
989
-                $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
990
-              elseif( $dueExist )
991
-                $component2->setProperty( 'X-CURRENT-DUE', $datestring );
988
+              if ($dtendExist)
989
+                $component2->setProperty('X-CURRENT-DTEND', $datestring);
990
+              elseif ($dueExist)
991
+                $component2->setProperty('X-CURRENT-DUE', $datestring);
992 992
             }
993
-            $rend   = $component2->_date2timestamp( $rend );
993
+            $rend   = $component2->_date2timestamp($rend);
994 994
             $rstart = $recurkey;
995 995
             /* add repeating components within valid dates to output array, only start date */
996
-            if( $flat )
996
+            if ($flat)
997 997
               $result[] = $component2->copy(); // copy to output
998
-            elseif( $split ) {
999
-              if( $rend > $endDate )
998
+            elseif ($split) {
999
+              if ($rend > $endDate)
1000 1000
                 $rend = $endDate;
1001
-              while( $rstart <= $rend ) { // iterate
1002
-                $wd = getdate( $rstart );
1003
-                if(( $rstart > $startDate ) &&      // date after dtstart
1004
-                    !isset( $exdatelist[$rstart] )) // check exclude date
1001
+              while ($rstart <= $rend) { // iterate
1002
+                $wd = getdate($rstart);
1003
+                if (($rstart > $startDate) && // date after dtstart
1004
+                    !isset($exdatelist[$rstart])) // check exclude date
1005 1005
                   $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1006
-                $rstart += ( 24*60*60 ); // step one day
1006
+                $rstart += (24 * 60 * 60); // step one day
1007 1007
               }
1008 1008
             }
1009
-            elseif(( $rstart >= $startDate ) &&     // date within period
1010
-                  !isset( $exdatelist[$rstart] )) { // check exclude date
1011
-              $wd = getdate( $rstart );
1009
+            elseif (($rstart >= $startDate) && // date within period
1010
+                  !isset($exdatelist[$rstart])) { // check exclude date
1011
+              $wd = getdate($rstart);
1012 1012
               $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1013 1013
             }
1014 1014
           }
1015 1015
         }
1016 1016
             /* deselect components with startdate/enddate not within period */
1017
-        if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1017
+        if (($endWdate < $startDate) || ($startWdate > $endDate)) continue;
1018 1018
       }
1019 1019
             /* deselect components with startdate not within period */
1020
-      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1020
+      elseif (($startWdate < $startDate) || ($startWdate > $endDate)) continue;
1021 1021
             /* add selected components within valid dates to output array */
1022
-      if( $flat )
1022
+      if ($flat)
1023 1023
         $result[] = $component->copy(); // copy to output;
1024
-      elseif( $split ) {
1025
-        if( $endWdate > $endDate )
1026
-          $endWdate = $endDate;     // use period end date
1027
-        if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1028
-          if( $startWdate < $startDate )
1024
+      elseif ($split) {
1025
+        if ($endWdate > $endDate)
1026
+          $endWdate = $endDate; // use period end date
1027
+        if (!isset($exdatelist[$startWdate])) { // check excluded dates
1028
+          if ($startWdate < $startDate)
1029 1029
             $startWdate = $startDate; // use period start date
1030
-          while( $startWdate <= $endWdate ) { // iterate
1031
-            $wd = getdate( $startWdate );
1030
+          while ($startWdate <= $endWdate) { // iterate
1031
+            $wd = getdate($startWdate);
1032 1032
             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1033
-            $startWdate += ( 24*60*60 ); // step one day
1033
+            $startWdate += (24 * 60 * 60); // step one day
1034 1034
           }
1035 1035
         }
1036 1036
       } // use component date
1037
-      elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1038
-            ( $startWdate >= $startDate )) {          // within period
1039
-        $wd = getdate( $startWdate );
1037
+      elseif (!isset($exdatelist[$startWdate]) && // check excluded dates
1038
+            ($startWdate >= $startDate)) {          // within period
1039
+        $wd = getdate($startWdate);
1040 1040
         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041 1041
       }
1042 1042
     }
1043
-    if( 0 >= count( $result )) return FALSE;
1044
-    elseif( !$flat ) {
1045
-      foreach( $result as $y => $yeararr ) {
1046
-        foreach( $yeararr as $m => $montharr ) {
1047
-          ksort( $result[$y][$m] );
1043
+    if (0 >= count($result)) return FALSE;
1044
+    elseif (!$flat) {
1045
+      foreach ($result as $y => $yeararr) {
1046
+        foreach ($yeararr as $m => $montharr) {
1047
+          ksort($result[$y][$m]);
1048 1048
         }
1049
-        ksort( $result[$y] );
1049
+        ksort($result[$y]);
1050 1050
       }
1051
-      ksort( $result );
1051
+      ksort($result);
1052 1052
     }
1053 1053
     return $result;
1054 1054
   }
@@ -1062,48 +1062,48 @@  discard block
 block discarded – undo
1062 1062
  * @param mixed $arg2 optional, ordno if arg1 = component type
1063 1063
  * @return void
1064 1064
  */
1065
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066
-    if( '' >= $component->getConfig( 'language'))
1067
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
1068
-    $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1069
-    $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1070
-    $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1071
-    $component->setConfig( 'format',      $this->getConfig( 'format' ));
1072
-    if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) {
1073
-      unset( $component->propix );
1065
+  function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) {
1066
+    if ('' >= $component->getConfig('language'))
1067
+      $component->setConfig('language', $this->getConfig('language'));
1068
+    $component->setConfig('allowEmpty', $this->getConfig('allowEmpty'));
1069
+    $component->setConfig('nl', $this->getConfig('nl'));
1070
+    $component->setConfig('unique_id', $this->getConfig('unique_id'));
1071
+    $component->setConfig('format', $this->getConfig('format'));
1072
+    if (!in_array($component->objName, array('valarm', 'vtimezone'))) {
1073
+      unset($component->propix);
1074 1074
             /* make sure dtstamp and uid is set */
1075
-      $dummy1 = $component->getProperty( 'dtstamp' );
1076
-      $dummy2 = $component->getProperty( 'uid' );
1075
+      $dummy1 = $component->getProperty('dtstamp');
1076
+      $dummy2 = $component->getProperty('uid');
1077 1077
     }
1078
-    if( !$arg1 ) {
1078
+    if (!$arg1) {
1079 1079
       $this->components[] = $component->copy();
1080 1080
       return TRUE;
1081 1081
     }
1082 1082
     $argType = $index = null;
1083
-    if ( ctype_digit( (string) $arg1 )) {
1083
+    if (ctype_digit((string) $arg1)) {
1084 1084
       $argType = 'INDEX';
1085 1085
       $index   = (int) $arg1 - 1;
1086 1086
     }
1087
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1088
-      $argType = strtolower( $arg1 );
1089
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1087
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
1088
+      $argType = strtolower($arg1);
1089
+      $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0;
1090 1090
     }
1091 1091
     $cix1sC = 0;
1092
-    foreach ( $this->components as $cix => $component2) {
1093
-      if( empty( $component2 )) continue;
1094
-      unset( $component2->propix );
1095
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1092
+    foreach ($this->components as $cix => $component2) {
1093
+      if (empty($component2)) continue;
1094
+      unset($component2->propix);
1095
+      if (('INDEX' == $argType) && ($index == $cix)) {
1096 1096
         $this->components[$cix] = $component->copy();
1097 1097
         return TRUE;
1098 1098
       }
1099
-      elseif( $argType == $component2->objName ) {
1100
-        if( $index == $cix1sC ) {
1099
+      elseif ($argType == $component2->objName) {
1100
+        if ($index == $cix1sC) {
1101 1101
           $this->components[$cix] = $component->copy();
1102 1102
           return TRUE;
1103 1103
         }
1104 1104
         $cix1sC++;
1105 1105
       }
1106
-      elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1106
+      elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) {
1107 1107
         $this->components[$cix] = $component->copy();
1108 1108
         return TRUE;
1109 1109
       }
@@ -1124,79 +1124,79 @@  discard block
 block discarded – undo
1124 1124
  *
1125 1125
  */
1126 1126
   function sort() {
1127
-    if( is_array( $this->components )) {
1128
-      $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' );
1129
-      usort( $this->components, array( $this, '_cmpfcn' ));
1130
-    }
1131
-  }
1132
-  function _cmpfcn( $a, $b ) {
1133
-    if( empty( $a ))                                   return -1;
1134
-    if( empty( $b ))                                   return  1;
1135
-    if(  'vtimezone' == $a->objName)                   return -1;
1136
-    if(  'vtimezone' == $b->objName)                   return  1;
1137
-    $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1138
-    if( empty( $astart ) && isset( $a->dtstart['value'] ))
1127
+    if (is_array($this->components)) {
1128
+      $this->_sortkeys = array('year', 'month', 'day', 'hour', 'min', 'sec');
1129
+      usort($this->components, array($this, '_cmpfcn'));
1130
+    }
1131
+  }
1132
+  function _cmpfcn($a, $b) {
1133
+    if (empty($a))                                   return -1;
1134
+    if (empty($b))                                   return  1;
1135
+    if ('vtimezone' == $a->objName)                   return -1;
1136
+    if ('vtimezone' == $b->objName)                   return  1;
1137
+    $astart = (isset($a->xprop['X-CURRENT-DTSTART']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTSTART']['value']) : null;
1138
+    if (empty($astart) && isset($a->dtstart['value']))
1139 1139
       $astart = & $a->dtstart['value'];
1140
-    $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1141
-    if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1140
+    $bstart = (isset($b->xprop['X-CURRENT-DTSTART']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTSTART']['value']) : null;
1141
+    if (empty($bstart) && isset($b->dtstart['value']))
1142 1142
       $bstart = & $b->dtstart['value'];
1143
-    if(     empty( $astart ))                          return -1;
1144
-    elseif( empty( $bstart ))                          return  1;
1145
-    foreach( $this->_sortkeys as $key ) {
1146
-      if    ( empty( $astart[$key] ))                  return -1;
1147
-      elseif( empty( $bstart[$key] ))                  return  1;
1148
-      if    (        $astart[$key] == $bstart[$key])   continue;
1149
-      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1143
+    if (empty($astart))                          return -1;
1144
+    elseif (empty($bstart))                          return  1;
1145
+    foreach ($this->_sortkeys as $key) {
1146
+      if (empty($astart[$key]))                  return -1;
1147
+      elseif (empty($bstart[$key]))                  return  1;
1148
+      if ($astart[$key] == $bstart[$key])   continue;
1149
+      if (((int) $astart[$key]) < ((int) $bstart[$key]))
1150 1150
                                                        return -1;
1151
-      elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1151
+      elseif (((int) $astart[$key]) > ((int) $bstart[$key]))
1152 1152
                                                        return  1;
1153 1153
     }
1154
-    $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1155
-    if(     empty( $c ) && !empty( $a->dtend['value'] ))
1154
+    $c   = (isset($a->xprop['X-CURRENT-DTEND']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTEND']['value']) : null;
1155
+    if (empty($c) && !empty($a->dtend['value']))
1156 1156
       $c = & $a->dtend['value'];
1157
-    if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1158
-      $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1159
-    if(     empty( $c ) && !empty( $a->due['value'] ))
1157
+    if (empty($c) && isset($a->xprop['X-CURRENT-DUE']['value']))
1158
+      $c = $a->_date_time_string($a->xprop['X-CURRENT-DUE']['value']);
1159
+    if (empty($c) && !empty($a->due['value']))
1160 1160
       $c = & $a->due['value'];
1161
-    if(     empty( $c ) && !empty( $a->duration['value'] ))
1161
+    if (empty($c) && !empty($a->duration['value']))
1162 1162
       $c = $a->duration2date();
1163
-    $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1164
-    if(     empty( $d ) && !empty( $b->dtend['value'] ))
1163
+    $d   = (isset($b->xprop['X-CURRENT-DTEND']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTEND']['value']) : null;
1164
+    if (empty($d) && !empty($b->dtend['value']))
1165 1165
       $d = & $b->dtend['value'];
1166
-    if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1167
-      $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1168
-    if(     empty( $d ) && !empty( $b->due['value'] ))
1166
+    if (empty($d) && isset($b->xprop['X-CURRENT-DUE']['value']))
1167
+      $d = $b->_date_time_string($b->xprop['X-CURRENT-DUE']['value']);
1168
+    if (empty($d) && !empty($b->due['value']))
1169 1169
       $d = & $b->due['value'];
1170
-    if(     empty( $d ) && !empty( $b->duration['value'] ))
1170
+    if (empty($d) && !empty($b->duration['value']))
1171 1171
       $d = $b->duration2date();
1172
-    if(     empty( $c ))                               return -1;
1173
-    elseif( empty( $d ))                               return  1;
1174
-    foreach( $this->_sortkeys as $key ) {
1175
-      if    ( !isset( $c[$key] ))                      return -1;
1176
-      elseif( !isset( $d[$key] ))                      return  1;
1177
-      if    (         $c[$key] == $d[$key] )           continue;
1178
-      if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1179
-      elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
1180
-    }
1181
-    if( isset( $a->created['value'] ))
1172
+    if (empty($c))                               return -1;
1173
+    elseif (empty($d))                               return  1;
1174
+    foreach ($this->_sortkeys as $key) {
1175
+      if (!isset($c[$key]))                      return -1;
1176
+      elseif (!isset($d[$key]))                      return  1;
1177
+      if ($c[$key] == $d[$key])           continue;
1178
+      if (((int) $c[$key]) < ((int) $d[$key]))   return -1;
1179
+      elseif (((int) $c[$key]) > ((int) $d[$key]))   return  1;
1180
+    }
1181
+    if (isset($a->created['value']))
1182 1182
      $e = & $a->created['value'];
1183 1183
     else
1184 1184
      $e = & $a->dtstamp['value'];
1185
-    if( isset( $b->created['value'] ))
1185
+    if (isset($b->created['value']))
1186 1186
       $f = & $b->created['value'];
1187 1187
     else
1188 1188
       $f = & $b->dtstamp['value'];
1189
-    foreach( $this->_sortkeys as $key ) {
1190
-      if(       !isset( $e[$key] ))                    return -1;
1191
-      elseif(   !isset( $f[$key] ))                    return  1;
1192
-      if    (           $e[$key] == $f[$key] )         continue;
1193
-      if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1194
-      elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
1195
-    }
1196
-    if    ((            $a->uid['value'] ) <
1197
-           (            $b->uid['value'] ))            return -1;
1198
-    elseif((            $a->uid['value'] ) >
1199
-           (            $b->uid['value'] ))            return  1;
1189
+    foreach ($this->_sortkeys as $key) {
1190
+      if (!isset($e[$key]))                    return -1;
1191
+      elseif (!isset($f[$key]))                    return  1;
1192
+      if ($e[$key] == $f[$key])         continue;
1193
+      if (((int) $e[$key]) < ((int) $f[$key])) return -1;
1194
+      elseif (((int) $e[$key]) > ((int) $f[$key])) return  1;
1195
+    }
1196
+    if (($a->uid['value']) <
1197
+           ($b->uid['value']))            return -1;
1198
+    elseif (($a->uid['value']) >
1199
+           ($b->uid['value']))            return  1;
1200 1200
     return 0;
1201 1201
   }
1202 1202
 /**
@@ -1208,104 +1208,104 @@  discard block
 block discarded – undo
1208 1208
  * @return bool FALSE if error occurs during parsing
1209 1209
  *
1210 1210
  */
1211
-  function parse( $filename=FALSE ) {
1212
-    if( !$filename ) {
1211
+  function parse($filename = FALSE) {
1212
+    if (!$filename) {
1213 1213
             /* directory/filename previous set via setConfig directory+filename / url */
1214
-      if( FALSE === ( $filename = $this->getConfig( 'url' )))
1215
-        $filename = $this->getConfig( 'dirfile' );
1214
+      if (FALSE === ($filename = $this->getConfig('url')))
1215
+        $filename = $this->getConfig('dirfile');
1216 1216
     }
1217
-    elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1218
-           ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1217
+    elseif (('http://' == strtolower(substr($filename, 0, 7))) ||
1218
+           ('webcal://' == strtolower(substr($filename, 0, 9)))) {
1219 1219
             /* remote file - URL */
1220
-      $this->setConfig( 'URL', $filename );
1221
-      if( !$filename = $this->getConfig( 'url' ))
1222
-        return FALSE;                 /* err 2 */
1220
+      $this->setConfig('URL', $filename);
1221
+      if (!$filename = $this->getConfig('url'))
1222
+        return FALSE; /* err 2 */
1223 1223
     }
1224 1224
     else {
1225 1225
             /* local directory/filename */
1226
-      $parts = pathinfo( $filename );
1227
-      if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1228
-        if( !$this->setConfig( 'directory', $parts['dirname'] ))
1229
-          return FALSE;               /* err 3 */
1226
+      $parts = pathinfo($filename);
1227
+      if (!empty($parts['dirname']) && ('.' != $parts['dirname'])) {
1228
+        if (!$this->setConfig('directory', $parts['dirname']))
1229
+          return FALSE; /* err 3 */
1230 1230
       }
1231
-      if( !$this->setConfig( 'filename', $parts['basename'] ))
1232
-        return FALSE;                 /* err 4 */
1231
+      if (!$this->setConfig('filename', $parts['basename']))
1232
+        return FALSE; /* err 4 */
1233 1233
     }
1234
-    if( 'http://' != substr( $filename, 0, 7 )) {
1234
+    if ('http://' != substr($filename, 0, 7)) {
1235 1235
             /* local file error tests */
1236
-      if( !is_file( $filename ))      /* err 5 */
1236
+      if (!is_file($filename))      /* err 5 */
1237 1237
         return FALSE;
1238
-      if( !is_readable( $filename ))
1239
-        return FALSE;                 /* err 6 */
1240
-      if( !filesize( $filename ))
1241
-        return FALSE;                 /* err 7 */
1238
+      if (!is_readable($filename))
1239
+        return FALSE; /* err 6 */
1240
+      if (!filesize($filename))
1241
+        return FALSE; /* err 7 */
1242 1242
       clearstatcache();
1243 1243
     }
1244 1244
             /* READ FILE */
1245
-    if( FALSE === ( $rows = file( $filename )))
1246
-      return FALSE;                   /* err 1 */
1245
+    if (FALSE === ($rows = file($filename)))
1246
+      return FALSE; /* err 1 */
1247 1247
             /* identify BEGIN:VCALENDAR, MUST be first row */
1248
-    if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1249
-      return FALSE;                   /* err 8 */
1248
+    if ('BEGIN:VCALENDAR' != strtoupper(trim($rows[0])))
1249
+      return FALSE; /* err 8 */
1250 1250
             /* remove empty trailing lines */
1251
-    while( '' == trim( $rows[count( $rows ) - 1] )) {
1252
-      unset( $rows[count( $rows ) - 1] );
1253
-      $rows  = array_values( $rows );
1251
+    while ('' == trim($rows[count($rows) - 1])) {
1252
+      unset($rows[count($rows) - 1]);
1253
+      $rows = array_values($rows);
1254 1254
     }
1255 1255
             /* identify ending END:VCALENDAR row */
1256
-    if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1257
-      return FALSE;                   /* err 9 */
1256
+    if ('END:VCALENDAR' != strtoupper(trim($rows[count($rows) - 1]))) {
1257
+      return FALSE; /* err 9 */
1258 1258
     }
1259
-    if( 3 > count( $rows ))
1260
-      return FALSE;                   /* err 10 */
1259
+    if (3 > count($rows))
1260
+      return FALSE; /* err 10 */
1261 1261
     $comp    = $subcomp = null;
1262 1262
     $actcomp = & $this;
1263
-    $nl      = $this->getConfig( 'nl' );
1263
+    $nl      = $this->getConfig('nl');
1264 1264
     $calsync = 0;
1265 1265
             /* identify components and update unparsed data within component */
1266
-    foreach( $rows as $line ) {
1267
-      if( '' == trim( $line ))
1266
+    foreach ($rows as $line) {
1267
+      if ('' == trim($line))
1268 1268
         continue;
1269
-      if( $nl == substr( $line, 0 - strlen( $nl )))
1270
-        $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1271
-      if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1269
+      if ($nl == substr($line, 0 - strlen($nl)))
1270
+        $line = substr($line, 0, (strlen($line) - strlen($nl))).'\n';
1271
+      if ('BEGIN:VCALENDAR' == strtoupper(substr($line, 0, 15))) {
1272 1272
         $calsync++;
1273 1273
         continue;
1274 1274
       }
1275
-      elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1275
+      elseif ('END:VCALENDAR' == strtoupper(substr($line, 0, 13))) {
1276 1276
         $calsync--;
1277 1277
         continue;
1278 1278
       }
1279
-      elseif( 1 != $calsync )
1280
-        return FALSE;                 /* err 20 */
1281
-      if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1282
-        if( null != $subcomp ) {
1283
-          $comp->setComponent( $subcomp );
1279
+      elseif (1 != $calsync)
1280
+        return FALSE; /* err 20 */
1281
+      if ('END:' == strtoupper(substr($line, 0, 4))) {
1282
+        if (null != $subcomp) {
1283
+          $comp->setComponent($subcomp);
1284 1284
           $subcomp = null;
1285 1285
         }
1286 1286
         else {
1287
-          $this->setComponent( $comp );
1287
+          $this->setComponent($comp);
1288 1288
           $comp = null;
1289 1289
         }
1290 1290
         $actcomp = null;
1291 1291
         continue;
1292 1292
       } // end - if ( 'END:' ==.. .
1293
-      elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) {
1294
-        $line = str_replace( '\n', '', $line );
1295
-        $compname = trim (strtoupper( substr( $line, 6 )));
1296
-        if( null != $comp ) {
1297
-          if( 'VALARM' == $compname )
1293
+      elseif ('BEGIN:' == strtoupper(substr($line, 0, 6))) {
1294
+        $line = str_replace('\n', '', $line);
1295
+        $compname = trim(strtoupper(substr($line, 6)));
1296
+        if (null != $comp) {
1297
+          if ('VALARM' == $compname)
1298 1298
             $subcomp = new valarm();
1299
-          elseif( 'STANDARD' == $compname )
1300
-            $subcomp = new vtimezone( 'STANDARD' );
1301
-          elseif( 'DAYLIGHT' == $compname )
1302
-            $subcomp = new vtimezone( 'DAYLIGHT' );
1299
+          elseif ('STANDARD' == $compname)
1300
+            $subcomp = new vtimezone('STANDARD');
1301
+          elseif ('DAYLIGHT' == $compname)
1302
+            $subcomp = new vtimezone('DAYLIGHT');
1303 1303
           else
1304 1304
             return FALSE; /* err 6 */
1305 1305
           $actcomp = & $subcomp;
1306 1306
         }
1307 1307
         else {
1308
-          switch( $compname ) {
1308
+          switch ($compname) {
1309 1309
             case 'VALARM':
1310 1310
               $comp = new valarm();
1311 1311
               break;
@@ -1336,74 +1336,74 @@  discard block
 block discarded – undo
1336 1336
       $actcomp->unparsed[] = $line;
1337 1337
     } // end - foreach( rows.. .
1338 1338
             /* parse data for calendar (this) object */
1339
-    if( is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) {
1339
+    if (is_array($this->unparsed) && (0 < count($this->unparsed))) {
1340 1340
             /* concatenate property values spread over several lines */
1341 1341
       $lastix    = -1;
1342
-      $propnames = array( 'calscale','method','prodid','version','x-' );
1342
+      $propnames = array('calscale', 'method', 'prodid', 'version', 'x-');
1343 1343
       $proprows  = array();
1344
-      foreach( $this->unparsed as $line ) {
1344
+      foreach ($this->unparsed as $line) {
1345 1345
         $newProp = FALSE;
1346
-        foreach ( $propnames as $propname ) {
1347
-          if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
1346
+        foreach ($propnames as $propname) {
1347
+          if ($propname == strtolower(substr($line, 0, strlen($propname)))) {
1348 1348
             $newProp = TRUE;
1349 1349
             break;
1350 1350
           }
1351 1351
         }
1352
-        if( $newProp ) {
1352
+        if ($newProp) {
1353 1353
           $newProp = FALSE;
1354 1354
           $lastix++;
1355
-          $proprows[$lastix]  = $line;
1355
+          $proprows[$lastix] = $line;
1356 1356
         }
1357 1357
         else {
1358 1358
             /* remove line breaks */
1359
-          if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1360
-             (  ' ' == substr( $line, 0, 1 ))) {
1361
-            $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
1362
-            $line = substr( $line, 1 );
1359
+          if (('\n' == substr($proprows[$lastix], -2)) &&
1360
+             (' ' == substr($line, 0, 1))) {
1361
+            $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2);
1362
+            $line = substr($line, 1);
1363 1363
           }
1364 1364
           $proprows[$lastix] .= $line;
1365 1365
         }
1366 1366
       }
1367 1367
       $toolbox = new calendarComponent();
1368
-      foreach( $proprows as $line ) {
1369
-        if( '\n' == substr( $line, -2 ))
1370
-          $line = substr( $line, 0, strlen( $line ) - 2 );
1368
+      foreach ($proprows as $line) {
1369
+        if ('\n' == substr($line, -2))
1370
+          $line = substr($line, 0, strlen($line) - 2);
1371 1371
             /* get propname */
1372 1372
         $cix = $propname = null;
1373
-        for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1374
-          if( in_array( $line{$cix}, array( ':', ';' )))
1373
+        for ($cix = 0; $cix < strlen($line); $cix++) {
1374
+          if (in_array($line{$cix}, array(':', ';')))
1375 1375
             break;
1376 1376
           else
1377 1377
             $propname .= $line{$cix};
1378 1378
         }
1379 1379
             /* ignore version/prodid properties */
1380
-        if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1380
+        if (in_array(strtoupper($propname), array('VERSION', 'PRODID')))
1381 1381
           continue;
1382
-        $line = substr( $line, $cix);
1382
+        $line = substr($line, $cix);
1383 1383
             /* separate attributes from value */
1384 1384
         $attr   = array();
1385 1385
         $attrix = -1;
1386
-        $strlen = strlen( $line );
1387
-        for( $cix=0; $cix < $strlen; $cix++ ) {
1388
-          if((       ':'   == $line{$cix} )             &&
1389
-                   ( '://' != substr( $line, $cix, 3 )) &&
1390
-             ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
1386
+        $strlen = strlen($line);
1387
+        for ($cix = 0; $cix < $strlen; $cix++) {
1388
+          if ((':' == $line{$cix} ) &&
1389
+                   ('://' != substr($line, $cix, 3)) &&
1390
+             ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) {
1391 1391
             $attrEnd = TRUE;
1392
-            if(( $cix < ( $strlen - 4 )) &&
1393
-                 ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
1394
-              for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
1395
-                if( '://' == substr( $line, $c2ix - 2, 3 )) {
1392
+            if (($cix < ($strlen - 4)) &&
1393
+                 ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr??
1394
+              for ($c2ix = $cix; 3 < $c2ix; $c2ix--) {
1395
+                if ('://' == substr($line, $c2ix - 2, 3)) {
1396 1396
                   $attrEnd = FALSE;
1397 1397
                   break; // an URI with a portnr!!
1398 1398
                 }
1399 1399
               }
1400 1400
             }
1401
-            if( $attrEnd) {
1402
-              $line = substr( $line, $cix + 1 );
1401
+            if ($attrEnd) {
1402
+              $line = substr($line, $cix + 1);
1403 1403
               break;
1404 1404
             }
1405 1405
           }
1406
-          if( ';' == $line{$cix} )
1406
+          if (';' == $line{$cix} )
1407 1407
             $attr[++$attrix] = null;
1408 1408
           else
1409 1409
             $attr[$attrix] .= $line{$cix};
@@ -1411,46 +1411,46 @@  discard block
 block discarded – undo
1411 1411
 
1412 1412
             /* make attributes in array format */
1413 1413
         $propattr = array();
1414
-        foreach( $attr as $attribute ) {
1415
-          $attrsplit = explode( '=', $attribute, 2 );
1416
-          if( 1 < count( $attrsplit ))
1414
+        foreach ($attr as $attribute) {
1415
+          $attrsplit = explode('=', $attribute, 2);
1416
+          if (1 < count($attrsplit))
1417 1417
             $propattr[$attrsplit[0]] = $attrsplit[1];
1418 1418
           else
1419 1419
             $propattr[] = $attribute;
1420 1420
         }
1421 1421
             /* update Property */
1422
-        if( FALSE !== strpos( $line, ',' )) {
1423
-          $content  = explode( ',', $line );
1424
-          $clen     = count( $content );
1425
-          for( $cix = 0; $cix < $clen; $cix++ ) {
1426
-            if( "\\" == substr( $content[$cix], -1 )) {
1422
+        if (FALSE !== strpos($line, ',')) {
1423
+          $content  = explode(',', $line);
1424
+          $clen     = count($content);
1425
+          for ($cix = 0; $cix < $clen; $cix++) {
1426
+            if ("\\" == substr($content[$cix], -1)) {
1427 1427
               $content[$cix] .= ','.$content[$cix + 1];
1428
-              unset( $content[$cix + 1] );
1428
+              unset($content[$cix + 1]);
1429 1429
               $cix++;
1430 1430
             }
1431 1431
           }
1432
-          if( 1 < count( $content )) {
1433
-            foreach( $content as $cix => $contentPart )
1434
-              $content[$cix] = $toolbox->_strunrep( $contentPart );
1435
-            $this->setProperty( $propname, $content, $propattr );
1432
+          if (1 < count($content)) {
1433
+            foreach ($content as $cix => $contentPart)
1434
+              $content[$cix] = $toolbox->_strunrep($contentPart);
1435
+            $this->setProperty($propname, $content, $propattr);
1436 1436
             continue;
1437 1437
           }
1438 1438
           else
1439
-            $line = reset( $content );
1440
-          $line = $toolbox->_strunrep( $line );
1439
+            $line = reset($content);
1440
+          $line = $toolbox->_strunrep($line);
1441 1441
         }
1442
-        $this->setProperty( $propname, trim( $line ), $propattr );
1442
+        $this->setProperty($propname, trim($line), $propattr);
1443 1443
       } // end - foreach( $this->unparsed.. .
1444 1444
     } // end - if( is_array( $this->unparsed.. .
1445 1445
             /* parse Components */
1446
-    if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1447
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
1448
-        if( !empty( $this->components[$six] ))
1446
+    if (is_array($this->components) && (0 < count($this->components))) {
1447
+      for ($six = 0; $six < count($this->components); $six++) {
1448
+        if (!empty($this->components[$six]))
1449 1449
           $this->components[$six]->parse();
1450 1450
       }
1451 1451
     }
1452 1452
     else
1453
-      return FALSE;                   /* err 91 or something.. . */
1453
+      return FALSE; /* err 91 or something.. . */
1454 1454
     return TRUE;
1455 1455
   }
1456 1456
 /*********************************************************************************/
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
  */
1464 1464
   function createCalendar() {
1465 1465
     $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null;
1466
-    switch( $this->format ) {
1466
+    switch ($this->format) {
1467 1467
       case 'xcal':
1468 1468
         $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl.
1469 1469
                          '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
@@ -1479,38 +1479,38 @@  discard block
 block discarded – undo
1479 1479
     $calendarStart .= $this->createMethod();
1480 1480
     $calendarStart .= $this->createProdid();
1481 1481
     $calendarStart .= $this->createVersion();
1482
-    switch( $this->format ) {
1482
+    switch ($this->format) {
1483 1483
       case 'xcal':
1484
-        $nlstrlen = strlen( $this->nl );
1485
-        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1486
-          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1484
+        $nlstrlen = strlen($this->nl);
1485
+        if ($this->nl == substr($calendarStart, (0 - $nlstrlen)))
1486
+          $calendarStart = substr($calendarStart, 0, (strlen($calendarStart) - $nlstrlen));
1487 1487
         $calendarStart .= '>'.$this->nl;
1488 1488
         break;
1489 1489
       default:
1490 1490
         break;
1491 1491
     }
1492 1492
     $calendar .= $this->createXprop();
1493
-    foreach( $this->components as $component ) {
1494
-      if( empty( $component )) continue;
1495
-      if( '' >= $component->getConfig( 'language'))
1496
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
1497
-      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1498
-      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1499
-      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1500
-      $component->setConfig( 'format',      $this->getConfig( 'format' ));
1501
-      $calendar .= $component->createComponent( $this->xcaldecl );
1502
-    }
1503
-    if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only
1493
+    foreach ($this->components as $component) {
1494
+      if (empty($component)) continue;
1495
+      if ('' >= $component->getConfig('language'))
1496
+        $component->setConfig('language', $this->getConfig('language'));
1497
+      $component->setConfig('allowEmpty', $this->getConfig('allowEmpty'));
1498
+      $component->setConfig('nl', $this->getConfig('nl'));
1499
+      $component->setConfig('unique_id', $this->getConfig('unique_id'));
1500
+      $component->setConfig('format', $this->getConfig('format'));
1501
+      $calendar .= $component->createComponent($this->xcaldecl);
1502
+    }
1503
+    if ((0 < count($this->xcaldecl)) && ('xcal' == $this->format)) { // xCal only
1504 1504
       $calendarInit1 .= $this->nl.'['.$this->nl;
1505 1505
       $old_xcaldecl = array();
1506
-      foreach( $this->xcaldecl as $declix => $declPart ) {
1507
-        if(( 0 < count( $old_xcaldecl)) &&
1508
-           ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1509
-           ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1506
+      foreach ($this->xcaldecl as $declix => $declPart) {
1507
+        if ((0 < count($old_xcaldecl)) &&
1508
+           (in_array($declPart['uri'], $old_xcaldecl['uri'])) &&
1509
+           (in_array($declPart['external'], $old_xcaldecl['external'])))
1510 1510
           continue; // no duplicate uri and ext. references
1511 1511
         $calendarxCaldecl .= '<!';
1512
-        foreach( $declPart as $declKey => $declValue ) {
1513
-          switch( $declKey ) {                    // index
1512
+        foreach ($declPart as $declKey => $declValue) {
1513
+          switch ($declKey) {                    // index
1514 1514
             case 'xmldecl':                       // no 1
1515 1515
               $calendarxCaldecl .= $declValue.' ';
1516 1516
               break;
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
       }
1538 1538
       $calendarInit2 = ']'.$calendarInit2;
1539 1539
     }
1540
-    switch( $this->format ) {
1540
+    switch ($this->format) {
1541 1541
       case 'xcal':
1542 1542
         $calendar .= '</vcalendar>'.$this->nl;
1543 1543
         break;
@@ -1555,18 +1555,18 @@  discard block
 block discarded – undo
1555 1555
  * @return redirect
1556 1556
  */
1557 1557
   function returnCalendar() {
1558
-    $filename = $this->getConfig( 'filename' );
1558
+    $filename = $this->getConfig('filename');
1559 1559
     $output   = $this->createCalendar();
1560
-    $filesize = strlen( $output );
1560
+    $filesize = strlen($output);
1561 1561
 //    if( headers_sent( $filename, $linenum ))
1562 1562
 //      die( "Headers already sent in $filename on line $linenum\n" );
1563
-    if( 'xcal' == $this->format )
1564
-      header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1563
+    if ('xcal' == $this->format)
1564
+      header('Content-Type: application/calendar+xml; charset=utf-8');
1565 1565
     else
1566
-      header( 'Content-Type: text/calendar; charset=utf-8' );
1567
-    header( 'Content-Length: '.$filesize );
1568
-    header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1569
-    header( 'Cache-Control: max-age=10' );
1566
+      header('Content-Type: text/calendar; charset=utf-8');
1567
+    header('Content-Length: '.$filesize);
1568
+    header('Content-Disposition: attachment; filename="'.$filename.'"');
1569
+    header('Cache-Control: max-age=10');
1570 1570
     echo $output;
1571 1571
     die();
1572 1572
   }
@@ -1580,20 +1580,20 @@  discard block
 block discarded – undo
1580 1580
  * @param string $delimiter optional
1581 1581
  * @return bool
1582 1582
  */
1583
-  function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1584
-    if( $directory )
1585
-      $this->setConfig( 'directory', $directory );
1586
-    if( $filename )
1587
-      $this->setConfig( 'filename',  $filename );
1588
-    if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1589
-      $this->setConfig( 'delimiter', $delimiter );
1590
-    if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1591
-      $dirfile = $this->getConfig( 'dirfile' );
1592
-    $iCalFile = @fopen( $dirfile, 'w' );
1593
-    if( $iCalFile ) {
1594
-      if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1583
+  function saveCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE) {
1584
+    if ($directory)
1585
+      $this->setConfig('directory', $directory);
1586
+    if ($filename)
1587
+      $this->setConfig('filename', $filename);
1588
+    if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR))
1589
+      $this->setConfig('delimiter', $delimiter);
1590
+    if (FALSE === ($dirfile = $this->getConfig('url')))
1591
+      $dirfile = $this->getConfig('dirfile');
1592
+    $iCalFile = @fopen($dirfile, 'w');
1593
+    if ($iCalFile) {
1594
+      if (FALSE === fwrite($iCalFile, $this->createCalendar()))
1595 1595
         return FALSE;
1596
-      fclose( $iCalFile );
1596
+      fclose($iCalFile);
1597 1597
       return TRUE;
1598 1598
     }
1599 1599
     else
@@ -1611,38 +1611,38 @@  discard block
 block discarded – undo
1611 1611
  * @param int timeout optional, default 3600 sec
1612 1612
  * @return redirect/FALSE
1613 1613
  */
1614
-  function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) {
1615
-    if ( $directory && ctype_digit( (string) $directory ) && !$filename ) {
1614
+  function useCachedCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE, $timeout = 3600) {
1615
+    if ($directory && ctype_digit((string) $directory) && !$filename) {
1616 1616
       $timeout   = (int) $directory;
1617 1617
       $directory = FALSE;
1618 1618
     }
1619
-    if( $directory )
1620
-      $this->setConfig( 'directory', $directory );
1621
-    if( $filename )
1622
-      $this->setConfig( 'filename',  $filename );
1623
-    if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1624
-      $this->setConfig( 'delimiter', $delimiter );
1625
-    $filesize    = $this->getConfig( 'filesize' );
1626
-    if( 0 >= $filesize )
1619
+    if ($directory)
1620
+      $this->setConfig('directory', $directory);
1621
+    if ($filename)
1622
+      $this->setConfig('filename', $filename);
1623
+    if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR))
1624
+      $this->setConfig('delimiter', $delimiter);
1625
+    $filesize    = $this->getConfig('filesize');
1626
+    if (0 >= $filesize)
1627 1627
       return FALSE;
1628
-    $dirfile     = $this->getConfig( 'dirfile' );
1629
-    if( time() - filemtime( $dirfile ) < $timeout) {
1628
+    $dirfile     = $this->getConfig('dirfile');
1629
+    if (time() - filemtime($dirfile) < $timeout) {
1630 1630
       clearstatcache();
1631
-      $dirfile   = $this->getConfig( 'dirfile' );
1632
-      $filename  = $this->getConfig( 'filename' );
1631
+      $dirfile   = $this->getConfig('dirfile');
1632
+      $filename  = $this->getConfig('filename');
1633 1633
 //    if( headers_sent( $filename, $linenum ))
1634 1634
 //      die( "Headers already sent in $filename on line $linenum\n" );
1635
-      if( 'xcal' == $this->format )
1636
-        header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1635
+      if ('xcal' == $this->format)
1636
+        header('Content-Type: application/calendar+xml; charset=utf-8');
1637 1637
       else
1638
-        header( 'Content-Type: text/calendar; charset=utf-8' );
1639
-      header( 'Content-Length: '.$filesize );
1640
-      header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1641
-      header( 'Cache-Control: max-age=10' );
1642
-      $fp = @$fopen( $dirfile, 'r' );
1643
-      if( $fp ) {
1644
-        fpassthru( $fp );
1645
-        fclose( $fp );
1638
+        header('Content-Type: text/calendar; charset=utf-8');
1639
+      header('Content-Length: '.$filesize);
1640
+      header('Content-Disposition: attachment; filename="'.$filename.'"');
1641
+      header('Cache-Control: max-age=10');
1642
+      $fp = @$fopen($dirfile, 'r');
1643
+      if ($fp) {
1644
+        fpassthru($fp);
1645
+        fclose($fp);
1646 1646
       }
1647 1647
       die();
1648 1648
     }
@@ -1691,8 +1691,8 @@  discard block
 block discarded – undo
1691 1691
  * @since 2.4.19 - 2008-10-23
1692 1692
  */
1693 1693
   function calendarComponent() {
1694
-    $this->objName         = ( isset( $this->timezonetype )) ?
1695
-                          strtolower( $this->timezonetype )  :  get_class ( $this );
1694
+    $this->objName         = (isset($this->timezonetype)) ?
1695
+                          strtolower($this->timezonetype) : get_class($this);
1696 1696
     $this->uid             = array();
1697 1697
     $this->dtstamp         = array();
1698 1698
 
@@ -1718,11 +1718,11 @@  discard block
 block discarded – undo
1718 1718
  * @return string
1719 1719
  */
1720 1720
   function createAction() {
1721
-    if( empty( $this->action )) return FALSE;
1722
-    if( empty( $this->action['value'] ))
1723
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1724
-    $attributes = $this->_createParams( $this->action['params'] );
1725
-    return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1721
+    if (empty($this->action)) return FALSE;
1722
+    if (empty($this->action['value']))
1723
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('ACTION') : FALSE;
1724
+    $attributes = $this->_createParams($this->action['params']);
1725
+    return $this->_createElement('ACTION', $attributes, $this->action['value']);
1726 1726
   }
1727 1727
 /**
1728 1728
  * set calendar component property action
@@ -1733,9 +1733,9 @@  discard block
 block discarded – undo
1733 1733
  * @param mixed $params
1734 1734
  * @return bool
1735 1735
  */
1736
-  function setAction( $value, $params=FALSE ) {
1737
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1738
-    $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1736
+  function setAction($value, $params = FALSE) {
1737
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
1738
+    $this->action = array('value' => $value, 'params' => $this->_setParams($params));
1739 1739
     return TRUE;
1740 1740
   }
1741 1741
 /*********************************************************************************/
@@ -1750,14 +1750,14 @@  discard block
 block discarded – undo
1750 1750
  * @return string
1751 1751
  */
1752 1752
   function createAttach() {
1753
-    if( empty( $this->attach )) return FALSE;
1754
-    $output       = null;
1755
-    foreach( $this->attach as $attachPart ) {
1756
-      if(! empty( $attachPart['value'] )) {
1757
-        $attributes = $this->_createParams( $attachPart['params'] );
1758
-        $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1753
+    if (empty($this->attach)) return FALSE;
1754
+    $output = null;
1755
+    foreach ($this->attach as $attachPart) {
1756
+      if (!empty($attachPart['value'])) {
1757
+        $attributes = $this->_createParams($attachPart['params']);
1758
+        $output    .= $this->_createElement('ATTACH', $attributes, $attachPart['value']);
1759 1759
       }
1760
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1760
+      elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('ATTACH');
1761 1761
     }
1762 1762
     return $output;
1763 1763
   }
@@ -1771,9 +1771,9 @@  discard block
 block discarded – undo
1771 1771
  * @param integer $index, optional
1772 1772
  * @return bool
1773 1773
  */
1774
-  function setAttach( $value, $params=FALSE, $index=FALSE ) {
1775
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1776
-    $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1774
+  function setAttach($value, $params = FALSE, $index = FALSE) {
1775
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
1776
+    $this->_setMval($this->attach, $value, $params, FALSE, $index);
1777 1777
     return TRUE;
1778 1778
   }
1779 1779
 /*********************************************************************************/
@@ -1788,26 +1788,26 @@  discard block
 block discarded – undo
1788 1788
  * @return string
1789 1789
  */
1790 1790
   function createAttendee() {
1791
-    if( empty( $this->attendee )) return FALSE;
1791
+    if (empty($this->attendee)) return FALSE;
1792 1792
     $output = null;
1793
-    foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1794
-      if( empty( $attendeePart['value'] )) {
1795
-        if( $this->getConfig( 'allowEmpty' ))
1796
-          $output .= $this->_createElement( 'ATTENDEE' );
1793
+    foreach ($this->attendee as $attendeePart) {                      // start foreach 1
1794
+      if (empty($attendeePart['value'])) {
1795
+        if ($this->getConfig('allowEmpty'))
1796
+          $output .= $this->_createElement('ATTENDEE');
1797 1797
         continue;
1798 1798
       }
1799 1799
       $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1800
-      foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1801
-        if( 'value' == $paramlabel )
1802
-          $attendee2  .= 'MAILTO:'.$paramvalue;
1803
-        elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1804
-          foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1800
+      foreach ($attendeePart as $paramlabel => $paramvalue) {         // start foreach 2
1801
+        if ('value' == $paramlabel)
1802
+          $attendee2 .= 'MAILTO:'.$paramvalue;
1803
+        elseif (('params' == $paramlabel) && (is_array($paramvalue))) { // start elseif
1804
+          foreach ($paramvalue as $optparamlabel => $optparamvalue) { // start foreach 3
1805 1805
             $attendee11 = $attendee12 = null;
1806
-            if( is_int( $optparamlabel )) {
1806
+            if (is_int($optparamlabel)) {
1807 1807
               $attendee1 .= $this->intAttrDelimiter.$optparamvalue;
1808 1808
               continue;
1809 1809
             }
1810
-            switch( $optparamlabel ) {                                 // start switch
1810
+            switch ($optparamlabel) {                                 // start switch
1811 1811
               case 'CUTYPE':
1812 1812
               case 'PARTSTAT':
1813 1813
               case 'ROLE':
@@ -1820,11 +1820,11 @@  discard block
 block discarded – undo
1820 1820
               case 'MEMBER':
1821 1821
                 $attendee11 = $this->intAttrDelimiter.'MEMBER=';
1822 1822
               case 'DELEGATED-TO':
1823
-                $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO='   : $attendee11;
1823
+                $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11;
1824 1824
               case 'DELEGATED-FROM':
1825
-                $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11;
1826
-                foreach( $optparamvalue  as $cix => $calUserAddress ) {
1827
-                  $attendee12 .= ( $cix ) ? ',' : null;
1825
+                $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11;
1826
+                foreach ($optparamvalue  as $cix => $calUserAddress) {
1827
+                  $attendee12 .= ($cix) ? ',' : null;
1828 1828
                   $attendee12 .= '"MAILTO:'.$calUserAddress.'"';
1829 1829
                 }
1830 1830
                 $attendee1  .= $attendee11.$attendee12;
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
           }      // end foreach 3
1846 1846
         }        // end elseif
1847 1847
       }          // end foreach 2
1848
-      $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 );
1848
+      $output .= $this->_createElement('ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2);
1849 1849
     }              // end foreach 1
1850 1850
     return $output;
1851 1851
   }
@@ -1859,63 +1859,63 @@  discard block
 block discarded – undo
1859 1859
  * @param integer $index, optional
1860 1860
  * @return bool
1861 1861
  */
1862
-  function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1863
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1864
-    $value = str_replace ( 'MAILTO:', '', $value );
1865
-    $value = str_replace ( 'mailto:', '', $value );
1862
+  function setAttendee($value, $params = FALSE, $index = FALSE) {
1863
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
1864
+    $value = str_replace('MAILTO:', '', $value);
1865
+    $value = str_replace('mailto:', '', $value);
1866 1866
     $params2 = array();
1867
-    if( is_array($params )) {
1867
+    if (is_array($params)) {
1868 1868
       $optarrays = array();
1869
-      foreach( $params as $optparamlabel => $optparamvalue ) {
1870
-        $optparamlabel = strtoupper( $optparamlabel );
1871
-        switch( $optparamlabel ) {
1869
+      foreach ($params as $optparamlabel => $optparamvalue) {
1870
+        $optparamlabel = strtoupper($optparamlabel);
1871
+        switch ($optparamlabel) {
1872 1872
           case 'MEMBER':
1873 1873
           case 'DELEGATED-TO':
1874 1874
           case 'DELEGATED-FROM':
1875
-            if( is_array( $optparamvalue )) {
1876
-              foreach( $optparamvalue as $part ) {
1877
-                $part = str_replace( 'MAILTO:', '', $part );
1878
-                $part = str_replace( 'mailto:', '', $part );
1879
-                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1880
-                  $part = substr( $part, 1, ( strlen($part)-2 ));
1875
+            if (is_array($optparamvalue)) {
1876
+              foreach ($optparamvalue as $part) {
1877
+                $part = str_replace('MAILTO:', '', $part);
1878
+                $part = str_replace('mailto:', '', $part);
1879
+                if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} ))
1880
+                  $part = substr($part, 1, (strlen($part) - 2));
1881 1881
                 $optarrays[$optparamlabel][] = $part;
1882 1882
               }
1883 1883
             }
1884 1884
             else {
1885
-              $part = str_replace( 'MAILTO:', '', $optparamvalue );
1886
-              $part = str_replace( 'mailto:', '', $part );
1887
-              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1888
-                $part = substr( $part, 1, ( strlen($part)-2 ));
1885
+              $part = str_replace('MAILTO:', '', $optparamvalue);
1886
+              $part = str_replace('mailto:', '', $part);
1887
+              if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} ))
1888
+                $part = substr($part, 1, (strlen($part) - 2));
1889 1889
               $optarrays[$optparamlabel][] = $part;
1890 1890
             }
1891 1891
             break;
1892 1892
           default:
1893
-            if( 'SENT-BY' ==  $optparamlabel ) {
1894
-              $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue );
1895
-              $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1893
+            if ('SENT-BY' == $optparamlabel) {
1894
+              $optparamvalue = str_replace('MAILTO:', '', $optparamvalue);
1895
+              $optparamvalue = str_replace('mailto:', '', $optparamvalue);
1896 1896
             }
1897
-            if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1898
-               ( '"' == substr( $optparamvalue, -1 )))
1899
-              $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
1897
+            if (('"' == substr($optparamvalue, 0, 1)) &&
1898
+               ('"' == substr($optparamvalue, -1)))
1899
+              $optparamvalue = substr($optparamvalue, 1, (strlen($optparamvalue) - 2));
1900 1900
             $params2[$optparamlabel] = $optparamvalue;
1901 1901
             break;
1902 1902
         } // end switch( $optparamlabel.. .
1903 1903
       } // end foreach( $optparam.. .
1904
-      foreach( $optarrays as $optparamlabel => $optparams )
1904
+      foreach ($optarrays as $optparamlabel => $optparams)
1905 1905
         $params2[$optparamlabel] = $optparams;
1906 1906
     }
1907 1907
         // remove defaults
1908
-    $this->_existRem( $params2, 'CUTYPE',   'INDIVIDUAL' );
1909
-    $this->_existRem( $params2, 'PARTSTAT', 'NEEDS-ACTION' );
1910
-    $this->_existRem( $params2, 'ROLE',     'REQ-PARTICIPANT' );
1911
-    $this->_existRem( $params2, 'RSVP',     'FALSE' );
1908
+    $this->_existRem($params2, 'CUTYPE', 'INDIVIDUAL');
1909
+    $this->_existRem($params2, 'PARTSTAT', 'NEEDS-ACTION');
1910
+    $this->_existRem($params2, 'ROLE', 'REQ-PARTICIPANT');
1911
+    $this->_existRem($params2, 'RSVP', 'FALSE');
1912 1912
         // check language setting
1913
-    if( isset( $params2['CN' ] )) {
1914
-      $lang = $this->getConfig( 'language' );
1915
-      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1916
-        $params2['LANGUAGE' ] = $lang;
1913
+    if (isset($params2['CN'])) {
1914
+      $lang = $this->getConfig('language');
1915
+      if (!isset($params2['LANGUAGE']) && !empty($lang))
1916
+        $params2['LANGUAGE'] = $lang;
1917 1917
     }
1918
-    $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1918
+    $this->_setMval($this->attendee, $value, $params2, FALSE, $index);
1919 1919
     return TRUE;
1920 1920
   }
1921 1921
 /*********************************************************************************/
@@ -1930,23 +1930,23 @@  discard block
 block discarded – undo
1930 1930
  * @return string
1931 1931
  */
1932 1932
   function createCategories() {
1933
-    if( empty( $this->categories )) return FALSE;
1933
+    if (empty($this->categories)) return FALSE;
1934 1934
     $output = null;
1935
-    foreach( $this->categories as $category ) {
1936
-      if( empty( $category['value'] )) {
1937
-        if ( $this->getConfig( 'allowEmpty' ))
1938
-          $output .= $this->_createElement( 'CATEGORIES' );
1935
+    foreach ($this->categories as $category) {
1936
+      if (empty($category['value'])) {
1937
+        if ($this->getConfig('allowEmpty'))
1938
+          $output .= $this->_createElement('CATEGORIES');
1939 1939
         continue;
1940 1940
       }
1941
-      $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1942
-      if( is_array( $category['value'] )) {
1943
-        foreach( $category['value'] as $cix => $categoryPart )
1944
-          $category['value'][$cix] = $this->_strrep( $categoryPart );
1945
-        $content  = implode( ',', $category['value'] );
1941
+      $attributes = $this->_createParams($category['params'], array('LANGUAGE'));
1942
+      if (is_array($category['value'])) {
1943
+        foreach ($category['value'] as $cix => $categoryPart)
1944
+          $category['value'][$cix] = $this->_strrep($categoryPart);
1945
+        $content  = implode(',', $category['value']);
1946 1946
       }
1947 1947
       else
1948
-        $content  = $this->_strrep( $category['value'] );
1949
-      $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1948
+        $content  = $this->_strrep($category['value']);
1949
+      $output    .= $this->_createElement('CATEGORIES', $attributes, $content);
1950 1950
     }
1951 1951
     return $output;
1952 1952
   }
@@ -1960,9 +1960,9 @@  discard block
 block discarded – undo
1960 1960
  * @param integer $index, optional
1961 1961
  * @return bool
1962 1962
  */
1963
-  function setCategories( $value, $params=FALSE, $index=FALSE ) {
1964
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1965
-    $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1963
+  function setCategories($value, $params = FALSE, $index = FALSE) {
1964
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
1965
+    $this->_setMval($this->categories, $value, $params, FALSE, $index);
1966 1966
     return TRUE;
1967 1967
  }
1968 1968
 /*********************************************************************************/
@@ -1977,11 +1977,11 @@  discard block
 block discarded – undo
1977 1977
  * @return string
1978 1978
  */
1979 1979
   function createClass() {
1980
-    if( empty( $this->class )) return FALSE;
1981
-    if( empty( $this->class['value'] ))
1982
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
1983
-    $attributes = $this->_createParams( $this->class['params'] );
1984
-    return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1980
+    if (empty($this->class)) return FALSE;
1981
+    if (empty($this->class['value']))
1982
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('CLASS') : FALSE;
1983
+    $attributes = $this->_createParams($this->class['params']);
1984
+    return $this->_createElement('CLASS', $attributes, $this->class['value']);
1985 1985
   }
1986 1986
 /**
1987 1987
  * set calendar component property class
@@ -1992,9 +1992,9 @@  discard block
 block discarded – undo
1992 1992
  * @param array $params optional
1993 1993
  * @return bool
1994 1994
  */
1995
-  function setClass( $value, $params=FALSE ) {
1996
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1997
-    $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1995
+  function setClass($value, $params = FALSE) {
1996
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
1997
+    $this->class = array('value' => $value, 'params' => $this->_setParams($params));
1998 1998
     return TRUE;
1999 1999
   }
2000 2000
 /*********************************************************************************/
@@ -2009,16 +2009,16 @@  discard block
 block discarded – undo
2009 2009
  * @return string
2010 2010
  */
2011 2011
   function createComment() {
2012
-    if( empty( $this->comment )) return FALSE;
2012
+    if (empty($this->comment)) return FALSE;
2013 2013
     $output = null;
2014
-    foreach( $this->comment as $commentPart ) {
2015
-      if( empty( $commentPart['value'] )) {
2016
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2014
+    foreach ($this->comment as $commentPart) {
2015
+      if (empty($commentPart['value'])) {
2016
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('COMMENT');
2017 2017
         continue;
2018 2018
       }
2019
-      $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
2020
-      $content    = $this->_strrep( $commentPart['value'] );
2021
-      $output    .= $this->_createElement( 'COMMENT', $attributes, $content );
2019
+      $attributes = $this->_createParams($commentPart['params'], array('ALTREP', 'LANGUAGE'));
2020
+      $content    = $this->_strrep($commentPart['value']);
2021
+      $output    .= $this->_createElement('COMMENT', $attributes, $content);
2022 2022
     }
2023 2023
     return $output;
2024 2024
   }
@@ -2032,9 +2032,9 @@  discard block
 block discarded – undo
2032 2032
  * @param integer $index, optional
2033 2033
  * @return bool
2034 2034
  */
2035
-  function setComment( $value, $params=FALSE, $index=FALSE ) {
2036
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2037
-    $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2035
+  function setComment($value, $params = FALSE, $index = FALSE) {
2036
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2037
+    $this->_setMval($this->comment, $value, $params, FALSE, $index);
2038 2038
     return TRUE;
2039 2039
   }
2040 2040
 /*********************************************************************************/
@@ -2049,19 +2049,19 @@  discard block
 block discarded – undo
2049 2049
  * @return string
2050 2050
  */
2051 2051
   function createCompleted( ) {
2052
-    if( empty( $this->completed )) return FALSE;
2053
-    if( !isset( $this->completed['value']['year'] )  &&
2054
-        !isset( $this->completed['value']['month'] ) &&
2055
-        !isset( $this->completed['value']['day'] )   &&
2056
-        !isset( $this->completed['value']['hour'] )  &&
2057
-        !isset( $this->completed['value']['min'] )   &&
2058
-        !isset( $this->completed['value']['sec'] ))
2059
-      if( $this->getConfig( 'allowEmpty' ))
2060
-        return $this->_createElement( 'COMPLETED' );
2052
+    if (empty($this->completed)) return FALSE;
2053
+    if (!isset($this->completed['value']['year']) &&
2054
+        !isset($this->completed['value']['month']) &&
2055
+        !isset($this->completed['value']['day']) &&
2056
+        !isset($this->completed['value']['hour']) &&
2057
+        !isset($this->completed['value']['min']) &&
2058
+        !isset($this->completed['value']['sec']))
2059
+      if ($this->getConfig('allowEmpty'))
2060
+        return $this->_createElement('COMPLETED');
2061 2061
       else return FALSE;
2062
-    $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2063
-    $attributes = $this->_createParams( $this->completed['params'] );
2064
-    return $this->_createElement( 'COMPLETED', $attributes, $formatted );
2062
+    $formatted  = $this->_format_date_time($this->completed['value'], 7);
2063
+    $attributes = $this->_createParams($this->completed['params']);
2064
+    return $this->_createElement('COMPLETED', $attributes, $formatted);
2065 2065
   }
2066 2066
 /**
2067 2067
  * set calendar component property completed
@@ -2077,16 +2077,16 @@  discard block
 block discarded – undo
2077 2077
  * @param array $params optional
2078 2078
  * @return bool
2079 2079
  */
2080
-  function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2081
-    if( empty( $year )) {
2082
-      if( $this->getConfig( 'allowEmpty' )) {
2083
-        $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2080
+  function setCompleted($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
2081
+    if (empty($year)) {
2082
+      if ($this->getConfig('allowEmpty')) {
2083
+        $this->completed = array('value' => null, 'params' => $this->_setParams($params));
2084 2084
         return TRUE;
2085 2085
       }
2086 2086
       else
2087 2087
         return FALSE;
2088 2088
     }
2089
-    $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2089
+    $this->completed = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params);
2090 2090
     return TRUE;
2091 2091
   }
2092 2092
 /*********************************************************************************/
@@ -2101,15 +2101,15 @@  discard block
 block discarded – undo
2101 2101
  * @return string
2102 2102
  */
2103 2103
   function createContact() {
2104
-    if( empty( $this->contact )) return FALSE;
2104
+    if (empty($this->contact)) return FALSE;
2105 2105
     $output = null;
2106
-    foreach( $this->contact as $contact ) {
2107
-      if( !empty( $contact['value'] )) {
2108
-        $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2109
-        $content    = $this->_strrep( $contact['value'] );
2110
-        $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2106
+    foreach ($this->contact as $contact) {
2107
+      if (!empty($contact['value'])) {
2108
+        $attributes = $this->_createParams($contact['params'], array('ALTREP', 'LANGUAGE'));
2109
+        $content    = $this->_strrep($contact['value']);
2110
+        $output    .= $this->_createElement('CONTACT', $attributes, $content);
2111 2111
       }
2112
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2112
+      elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('CONTACT');
2113 2113
     }
2114 2114
     return $output;
2115 2115
   }
@@ -2123,9 +2123,9 @@  discard block
 block discarded – undo
2123 2123
  * @param integer $index, optional
2124 2124
  * @return bool
2125 2125
  */
2126
-  function setContact( $value, $params=FALSE, $index=FALSE ) {
2127
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2128
-    $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2126
+  function setContact($value, $params = FALSE, $index = FALSE) {
2127
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2128
+    $this->_setMval($this->contact, $value, $params, FALSE, $index);
2129 2129
     return TRUE;
2130 2130
   }
2131 2131
 /*********************************************************************************/
@@ -2140,10 +2140,10 @@  discard block
 block discarded – undo
2140 2140
  * @return string
2141 2141
  */
2142 2142
   function createCreated() {
2143
-    if( empty( $this->created )) return FALSE;
2144
-    $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2145
-    $attributes = $this->_createParams( $this->created['params'] );
2146
-    return $this->_createElement( 'CREATED', $attributes, $formatted );
2143
+    if (empty($this->created)) return FALSE;
2144
+    $formatted  = $this->_format_date_time($this->created['value'], 7);
2145
+    $attributes = $this->_createParams($this->created['params']);
2146
+    return $this->_createElement('CREATED', $attributes, $formatted);
2147 2147
   }
2148 2148
 /**
2149 2149
  * set calendar component property created
@@ -2159,11 +2159,11 @@  discard block
 block discarded – undo
2159 2159
  * @param mixed $params optional
2160 2160
  * @return bool
2161 2161
  */
2162
-  function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2163
-    if( !isset( $year )) {
2164
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2162
+  function setCreated($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
2163
+    if (!isset($year)) {
2164
+      $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y')));
2165 2165
     }
2166
-    $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2166
+    $this->created = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params);
2167 2167
     return TRUE;
2168 2168
   }
2169 2169
 /*********************************************************************************/
@@ -2178,15 +2178,15 @@  discard block
 block discarded – undo
2178 2178
  * @return string
2179 2179
  */
2180 2180
   function createDescription() {
2181
-    if( empty( $this->description )) return FALSE;
2182
-    $output       = null;
2183
-    foreach( $this->description as $description ) {
2184
-      if( !empty( $description['value'] )) {
2185
-        $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2186
-        $content    = $this->_strrep( $description['value'] );
2187
-        $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2181
+    if (empty($this->description)) return FALSE;
2182
+    $output = null;
2183
+    foreach ($this->description as $description) {
2184
+      if (!empty($description['value'])) {
2185
+        $attributes = $this->_createParams($description['params'], array('ALTREP', 'LANGUAGE'));
2186
+        $content    = $this->_strrep($description['value']);
2187
+        $output    .= $this->_createElement('DESCRIPTION', $attributes, $content);
2188 2188
       }
2189
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2189
+      elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('DESCRIPTION');
2190 2190
     }
2191 2191
     return $output;
2192 2192
   }
@@ -2200,9 +2200,9 @@  discard block
 block discarded – undo
2200 2200
  * @param integer $index, optional
2201 2201
  * @return bool
2202 2202
  */
2203
-  function setDescription( $value, $params=FALSE, $index=FALSE ) {
2204
-    if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2205
-    $this->_setMval( $this->description, $value, $params, FALSE, $index );
2203
+  function setDescription($value, $params = FALSE, $index = FALSE) {
2204
+    if (empty($value)) { if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; }
2205
+    $this->_setMval($this->description, $value, $params, FALSE, $index);
2206 2206
     return TRUE;
2207 2207
   }
2208 2208
 /*********************************************************************************/
@@ -2217,19 +2217,19 @@  discard block
 block discarded – undo
2217 2217
  * @return string
2218 2218
  */
2219 2219
   function createDtend() {
2220
-    if( empty( $this->dtend )) return FALSE;
2221
-    if( !isset( $this->dtend['value']['year'] )  &&
2222
-        !isset( $this->dtend['value']['month'] ) &&
2223
-        !isset( $this->dtend['value']['day'] )   &&
2224
-        !isset( $this->dtend['value']['hour'] )  &&
2225
-        !isset( $this->dtend['value']['min'] )   &&
2226
-        !isset( $this->dtend['value']['sec'] ))
2227
-      if( $this->getConfig( 'allowEmpty' ))
2228
-        return $this->_createElement( 'DTEND' );
2220
+    if (empty($this->dtend)) return FALSE;
2221
+    if (!isset($this->dtend['value']['year']) &&
2222
+        !isset($this->dtend['value']['month']) &&
2223
+        !isset($this->dtend['value']['day']) &&
2224
+        !isset($this->dtend['value']['hour']) &&
2225
+        !isset($this->dtend['value']['min']) &&
2226
+        !isset($this->dtend['value']['sec']))
2227
+      if ($this->getConfig('allowEmpty'))
2228
+        return $this->_createElement('DTEND');
2229 2229
       else return FALSE;
2230
-    $formatted  = $this->_format_date_time( $this->dtend['value'] );
2231
-    $attributes = $this->_createParams( $this->dtend['params'] );
2232
-    return $this->_createElement( 'DTEND', $attributes, $formatted );
2230
+    $formatted  = $this->_format_date_time($this->dtend['value']);
2231
+    $attributes = $this->_createParams($this->dtend['params']);
2232
+    return $this->_createElement('DTEND', $attributes, $formatted);
2233 2233
   }
2234 2234
 /**
2235 2235
  * set calendar component property dtend
@@ -2246,16 +2246,16 @@  discard block
 block discarded – undo
2246 2246
  * @param array params optional
2247 2247
  * @return bool
2248 2248
  */
2249
-  function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2250
-    if( empty( $year )) {
2251
-      if( $this->getConfig( 'allowEmpty' )) {
2252
-        $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2249
+  function setDtend($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) {
2250
+    if (empty($year)) {
2251
+      if ($this->getConfig('allowEmpty')) {
2252
+        $this->dtend = array('value' => null, 'params' => $this->_setParams($params));
2253 2253
         return TRUE;
2254 2254
       }
2255 2255
       else
2256 2256
         return FALSE;
2257 2257
     }
2258
-    $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2258
+    $this->dtend = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params);
2259 2259
     return TRUE;
2260 2260
   }
2261 2261
 /*********************************************************************************/
@@ -2270,16 +2270,16 @@  discard block
 block discarded – undo
2270 2270
  * @return string
2271 2271
  */
2272 2272
   function createDtstamp() {
2273
-    if( !isset( $this->dtstamp['value']['year'] )  &&
2274
-        !isset( $this->dtstamp['value']['month'] ) &&
2275
-        !isset( $this->dtstamp['value']['day'] )   &&
2276
-        !isset( $this->dtstamp['value']['hour'] )  &&
2277
-        !isset( $this->dtstamp['value']['min'] )   &&
2278
-        !isset( $this->dtstamp['value']['sec'] ))
2273
+    if (!isset($this->dtstamp['value']['year']) &&
2274
+        !isset($this->dtstamp['value']['month']) &&
2275
+        !isset($this->dtstamp['value']['day']) &&
2276
+        !isset($this->dtstamp['value']['hour']) &&
2277
+        !isset($this->dtstamp['value']['min']) &&
2278
+        !isset($this->dtstamp['value']['sec']))
2279 2279
       $this->_makeDtstamp();
2280
-    $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2281
-    $attributes = $this->_createParams( $this->dtstamp['params'] );
2282
-    return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
2280
+    $formatted  = $this->_format_date_time($this->dtstamp['value'], 7);
2281
+    $attributes = $this->_createParams($this->dtstamp['params']);
2282
+    return $this->_createElement('DTSTAMP', $attributes, $formatted);
2283 2283
   }
2284 2284
 /**
2285 2285
  * computes datestamp for calendar component object instance dtstamp
@@ -2289,12 +2289,12 @@  discard block
 block discarded – undo
2289 2289
  * @return void
2290 2290
  */
2291 2291
   function _makeDtstamp() {
2292
-    $this->dtstamp['value'] = array( 'year'  => date( 'Y' )
2293
-                                   , 'month' => date( 'm' )
2294
-                                   , 'day'   => date( 'd' )
2295
-                                   , 'hour'  => date( 'H' )
2296
-                                   , 'min'   => date( 'i' )
2297
-                                   , 'sec'   => date( 's' ) - date( 'Z' ));
2292
+    $this->dtstamp['value'] = array('year'  => date('Y')
2293
+                                   , 'month' => date('m')
2294
+                                   , 'day'   => date('d')
2295
+                                   , 'hour'  => date('H')
2296
+                                   , 'min'   => date('i')
2297
+                                   , 'sec'   => date('s') - date('Z'));
2298 2298
     $this->dtstamp['params'] = null;
2299 2299
   }
2300 2300
 /**
@@ -2311,11 +2311,11 @@  discard block
 block discarded – undo
2311 2311
  * @param array $params optional
2312 2312
  * @return TRUE
2313 2313
  */
2314
-  function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315
-    if( empty( $year ))
2314
+  function setDtstamp($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
2315
+    if (empty($year))
2316 2316
       $this->_makeDtstamp();
2317 2317
     else
2318
-      $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2318
+      $this->dtstamp = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params);
2319 2319
     return TRUE;
2320 2320
   }
2321 2321
 /*********************************************************************************/
@@ -2330,21 +2330,21 @@  discard block
 block discarded – undo
2330 2330
  * @return string
2331 2331
  */
2332 2332
   function createDtstart() {
2333
-    if( empty( $this->dtstart )) return FALSE;
2334
-    if( !isset( $this->dtstart['value']['year'] )  &&
2335
-        !isset( $this->dtstart['value']['month'] ) &&
2336
-        !isset( $this->dtstart['value']['day'] )   &&
2337
-        !isset( $this->dtstart['value']['hour'] )  &&
2338
-        !isset( $this->dtstart['value']['min'] )   &&
2339
-        !isset( $this->dtstart['value']['sec'] ))
2340
-    if( $this->getConfig( 'allowEmpty' ))
2341
-      return $this->_createElement( 'DTSTART' );
2333
+    if (empty($this->dtstart)) return FALSE;
2334
+    if (!isset($this->dtstart['value']['year']) &&
2335
+        !isset($this->dtstart['value']['month']) &&
2336
+        !isset($this->dtstart['value']['day']) &&
2337
+        !isset($this->dtstart['value']['hour']) &&
2338
+        !isset($this->dtstart['value']['min']) &&
2339
+        !isset($this->dtstart['value']['sec']))
2340
+    if ($this->getConfig('allowEmpty'))
2341
+      return $this->_createElement('DTSTART');
2342 2342
     else return FALSE;
2343
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2344
-      unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2345
-    $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2346
-    $attributes = $this->_createParams( $this->dtstart['params'] );
2347
-    return $this->_createElement( 'DTSTART', $attributes, $formatted );
2343
+    if (in_array($this->objName, array('vtimezone', 'standard', 'daylight')))
2344
+      unset($this->dtstart['value']['tz'], $this->dtstart['params']['TZID']);
2345
+    $formatted  = $this->_format_date_time($this->dtstart['value']);
2346
+    $attributes = $this->_createParams($this->dtstart['params']);
2347
+    return $this->_createElement('DTSTART', $attributes, $formatted);
2348 2348
   }
2349 2349
 /**
2350 2350
  * set calendar component property dtstart
@@ -2361,16 +2361,16 @@  discard block
 block discarded – undo
2361 2361
  * @param array $params optional
2362 2362
  * @return bool
2363 2363
  */
2364
-  function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2365
-    if( empty( $year )) {
2366
-      if( $this->getConfig( 'allowEmpty' )) {
2367
-        $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2364
+  function setDtstart($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) {
2365
+    if (empty($year)) {
2366
+      if ($this->getConfig('allowEmpty')) {
2367
+        $this->dtstart = array('value' => null, 'params' => $this->_setParams($params));
2368 2368
         return TRUE;
2369 2369
       }
2370 2370
       else
2371 2371
         return FALSE;
2372 2372
     }
2373
-    $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2373
+    $this->dtstart = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart');
2374 2374
     return TRUE;
2375 2375
   }
2376 2376
 /*********************************************************************************/
@@ -2385,19 +2385,19 @@  discard block
 block discarded – undo
2385 2385
  * @return string
2386 2386
  */
2387 2387
   function createDue() {
2388
-    if( empty( $this->due )) return FALSE;
2389
-    if( !isset( $this->due['value']['year'] )  &&
2390
-        !isset( $this->due['value']['month'] ) &&
2391
-        !isset( $this->due['value']['day'] )   &&
2392
-        !isset( $this->due['value']['hour'] )  &&
2393
-        !isset( $this->due['value']['min'] )   &&
2394
-        !isset( $this->due['value']['sec'] ))
2395
-      if( $this->getConfig( 'allowEmpty' ))
2396
-        return $this->_createElement( 'DUE' );
2388
+    if (empty($this->due)) return FALSE;
2389
+    if (!isset($this->due['value']['year']) &&
2390
+        !isset($this->due['value']['month']) &&
2391
+        !isset($this->due['value']['day']) &&
2392
+        !isset($this->due['value']['hour']) &&
2393
+        !isset($this->due['value']['min']) &&
2394
+        !isset($this->due['value']['sec']))
2395
+      if ($this->getConfig('allowEmpty'))
2396
+        return $this->_createElement('DUE');
2397 2397
       else return FALSE;
2398
-    $formatted  = $this->_format_date_time( $this->due['value'] );
2399
-    $attributes = $this->_createParams( $this->due['params'] );
2400
-    return $this->_createElement( 'DUE', $attributes, $formatted );
2398
+    $formatted  = $this->_format_date_time($this->due['value']);
2399
+    $attributes = $this->_createParams($this->due['params']);
2400
+    return $this->_createElement('DUE', $attributes, $formatted);
2401 2401
   }
2402 2402
 /**
2403 2403
  * set calendar component property due
@@ -2413,16 +2413,16 @@  discard block
 block discarded – undo
2413 2413
  * @param array $params optional
2414 2414
  * @return bool
2415 2415
  */
2416
-  function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2417
-    if( empty( $year )) {
2418
-      if( $this->getConfig( 'allowEmpty' )) {
2419
-        $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2416
+  function setDue($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) {
2417
+    if (empty($year)) {
2418
+      if ($this->getConfig('allowEmpty')) {
2419
+        $this->due = array('value' => null, 'params' => $this->_setParams($params));
2420 2420
         return TRUE;
2421 2421
       }
2422 2422
       else
2423 2423
         return FALSE;
2424 2424
     }
2425
-    $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2425
+    $this->due = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params);
2426 2426
     return TRUE;
2427 2427
   }
2428 2428
 /*********************************************************************************/
@@ -2437,17 +2437,17 @@  discard block
 block discarded – undo
2437 2437
  * @return string
2438 2438
  */
2439 2439
   function createDuration() {
2440
-    if( empty( $this->duration )) return FALSE;
2441
-    if( !isset( $this->duration['value']['week'] ) &&
2442
-        !isset( $this->duration['value']['day'] )  &&
2443
-        !isset( $this->duration['value']['hour'] ) &&
2444
-        !isset( $this->duration['value']['min'] )  &&
2445
-        !isset( $this->duration['value']['sec'] ))
2446
-      if( $this->getConfig( 'allowEmpty' ))
2447
-        return $this->_createElement( 'DURATION', array(), null );
2440
+    if (empty($this->duration)) return FALSE;
2441
+    if (!isset($this->duration['value']['week']) &&
2442
+        !isset($this->duration['value']['day']) &&
2443
+        !isset($this->duration['value']['hour']) &&
2444
+        !isset($this->duration['value']['min']) &&
2445
+        !isset($this->duration['value']['sec']))
2446
+      if ($this->getConfig('allowEmpty'))
2447
+        return $this->_createElement('DURATION', array(), null);
2448 2448
       else return FALSE;
2449
-    $attributes = $this->_createParams( $this->duration['params'] );
2450
-    return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2449
+    $attributes = $this->_createParams($this->duration['params']);
2450
+    return $this->_createElement('DURATION', $attributes, $this->_format_duration($this->duration['value']));
2451 2451
   }
2452 2452
 /**
2453 2453
  * set calendar component property duration
@@ -2462,20 +2462,20 @@  discard block
 block discarded – undo
2462 2462
  * @param array $params optional
2463 2463
  * @return bool
2464 2464
  */
2465
-  function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2466
-    if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2467
-    if( is_array( $week ) && ( 1 <= count( $week )))
2468
-      $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2469
-    elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2470
-      $week = trim( $week );
2471
-      if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2472
-        $week = substr( $week, 1 );
2473
-      $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2474
-    }
2475
-    elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2465
+  function setDuration($week, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
2466
+    if (empty($week)) if ($this->getConfig('allowEmpty')) $week = null; else return FALSE;
2467
+    if (is_array($week) && (1 <= count($week)))
2468
+      $this->duration = array('value' => $this->_duration_array($week), 'params' => $this->_setParams($day));
2469
+    elseif (is_string($week) && (3 <= strlen(trim($week)))) {
2470
+      $week = trim($week);
2471
+      if (in_array(substr($week, 0, 1), array('+', '-')))
2472
+        $week = substr($week, 1);
2473
+      $this->duration = array('value' => $this->_duration_string($week), 'params' => $this->_setParams($day));
2474
+    }
2475
+    elseif (empty($week) && empty($day) && empty($hour) && empty($min) && empty($sec))
2476 2476
       return FALSE;
2477 2477
     else
2478
-      $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2478
+      $this->duration = array('value' => $this->_duration_array(array($week, $day, $hour, $min, $sec)), 'params' => $this->_setParams($params));
2479 2479
     return TRUE;
2480 2480
   }
2481 2481
 /*********************************************************************************/
@@ -2490,36 +2490,36 @@  discard block
 block discarded – undo
2490 2490
  * @return string
2491 2491
  */
2492 2492
   function createExdate() {
2493
-    if( empty( $this->exdate )) return FALSE;
2493
+    if (empty($this->exdate)) return FALSE;
2494 2494
     $output = null;
2495
-    foreach( $this->exdate as $ex => $theExdate ) {
2496
-      if( empty( $theExdate['value'] )) {
2497
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2495
+    foreach ($this->exdate as $ex => $theExdate) {
2496
+      if (empty($theExdate['value'])) {
2497
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('EXDATE');
2498 2498
         continue;
2499 2499
       }
2500 2500
       $content = $attributes = null;
2501
-      foreach( $theExdate['value'] as $eix => $exdatePart ) {
2502
-        $parno = count( $exdatePart );
2503
-        $formatted = $this->_format_date_time( $exdatePart, $parno );
2504
-        if( isset( $theExdate['params']['TZID'] ))
2505
-          $formatted = str_replace( 'Z', '', $formatted);
2506
-        if( 0 < $eix ) {
2507
-          if( isset( $theExdate['value'][0]['tz'] )) {
2508
-            if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2509
-               ( 'Z' == $theExdate['value'][0]['tz'] )) {
2510
-              if( 'Z' != substr( $formatted, -1 ))
2501
+      foreach ($theExdate['value'] as $eix => $exdatePart) {
2502
+        $parno = count($exdatePart);
2503
+        $formatted = $this->_format_date_time($exdatePart, $parno);
2504
+        if (isset($theExdate['params']['TZID']))
2505
+          $formatted = str_replace('Z', '', $formatted);
2506
+        if (0 < $eix) {
2507
+          if (isset($theExdate['value'][0]['tz'])) {
2508
+            if (ctype_digit(substr($theExdate['value'][0]['tz'], -4)) ||
2509
+               ('Z' == $theExdate['value'][0]['tz'])) {
2510
+              if ('Z' != substr($formatted, -1))
2511 2511
                 $formatted .= 'Z';
2512 2512
             }
2513 2513
             else
2514
-              $formatted = str_replace( 'Z', '', $formatted );
2514
+              $formatted = str_replace('Z', '', $formatted);
2515 2515
           }
2516 2516
           else
2517
-            $formatted = str_replace( 'Z', '', $formatted );
2517
+            $formatted = str_replace('Z', '', $formatted);
2518 2518
         }
2519
-        $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2519
+        $content .= (0 < $eix) ? ','.$formatted : $formatted;
2520 2520
       }
2521
-      $attributes .= $this->_createParams( $theExdate['params'] );
2522
-      $output .= $this->_createElement( 'EXDATE', $attributes, $content );
2521
+      $attributes .= $this->_createParams($theExdate['params']);
2522
+      $output .= $this->_createElement('EXDATE', $attributes, $content);
2523 2523
     }
2524 2524
     return $output;
2525 2525
   }
@@ -2533,44 +2533,44 @@  discard block
 block discarded – undo
2533 2533
  * @param integer $index, optional
2534 2534
  * @return bool
2535 2535
  */
2536
-  function setExdate( $exdates, $params=FALSE, $index=FALSE ) {
2537
-    if( empty( $exdates )) {
2538
-      if( $this->getConfig( 'allowEmpty' )) {
2539
-        $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2536
+  function setExdate($exdates, $params = FALSE, $index = FALSE) {
2537
+    if (empty($exdates)) {
2538
+      if ($this->getConfig('allowEmpty')) {
2539
+        $this->_setMval($this->exdate, null, $params, FALSE, $index);
2540 2540
         return TRUE;
2541 2541
       }
2542 2542
       else
2543 2543
         return FALSE;
2544 2544
     }
2545
-    $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
2545
+    $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME')));
2546 2546
             /* ev. check 1:st date and save ev. timezone **/
2547
-    $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2548
-    $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2549
-    foreach( $exdates as $eix => $theExdate ) {
2550
-      if( $this->_isArrayTimestampDate( $theExdate ))
2551
-        $exdatea = $this->_timestamp2date( $theExdate, $parno );
2552
-      elseif(  is_array( $theExdate ))
2553
-        $exdatea = $this->_date_time_array( $theExdate, $parno );
2554
-      elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2555
-        $exdatea = $this->_date_time_string( $theExdate, $parno );
2556
-      if( 3 == $parno )
2557
-        unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2558
-      elseif( isset( $exdatea['tz'] ))
2547
+    $this->_chkdatecfg(reset($exdates), $parno, $input['params']);
2548
+    $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default parameter
2549
+    foreach ($exdates as $eix => $theExdate) {
2550
+      if ($this->_isArrayTimestampDate($theExdate))
2551
+        $exdatea = $this->_timestamp2date($theExdate, $parno);
2552
+      elseif (is_array($theExdate))
2553
+        $exdatea = $this->_date_time_array($theExdate, $parno);
2554
+      elseif (8 <= strlen(trim($theExdate))) // ex. 2006-08-03 10:12:18
2555
+        $exdatea = $this->_date_time_string($theExdate, $parno);
2556
+      if (3 == $parno)
2557
+        unset($exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz']);
2558
+      elseif (isset($exdatea['tz']))
2559 2559
         $exdatea['tz'] = (string) $exdatea['tz'];
2560
-      if(  isset( $input['params']['TZID'] ) ||
2561
-         ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2562
-         ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2563
-         ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2564
-        unset( $exdatea['tz'] );
2560
+      if (isset($input['params']['TZID']) ||
2561
+         (isset($exdatea['tz']) && !$this->_isOffset($exdatea['tz'])) ||
2562
+         (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) ||
2563
+         (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz'])))
2564
+        unset($exdatea['tz']);
2565 2565
       $input['value'][] = $exdatea;
2566 2566
     }
2567
-    if( 0 >= count( $input['value'] ))
2567
+    if (0 >= count($input['value']))
2568 2568
       return FALSE;
2569
-    if( 3 == $parno ) {
2569
+    if (3 == $parno) {
2570 2570
       $input['params']['VALUE'] = 'DATE';
2571
-      unset( $input['params']['TZID'] );
2571
+      unset($input['params']['TZID']);
2572 2572
     }
2573
-    $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index );
2573
+    $this->_setMval($this->exdate, $input['value'], $input['params'], FALSE, $index);
2574 2574
     return TRUE;
2575 2575
   }
2576 2576
 /*********************************************************************************/
@@ -2585,8 +2585,8 @@  discard block
 block discarded – undo
2585 2585
  * @return string
2586 2586
  */
2587 2587
   function createExrule() {
2588
-    if( empty( $this->exrule )) return FALSE;
2589
-    return $this->_format_recur( 'EXRULE', $this->exrule );
2588
+    if (empty($this->exrule)) return FALSE;
2589
+    return $this->_format_recur('EXRULE', $this->exrule);
2590 2590
   }
2591 2591
 /**
2592 2592
  * set calendar component property exdate
@@ -2598,9 +2598,9 @@  discard block
 block discarded – undo
2598 2598
  * @param integer $index, optional
2599 2599
  * @return bool
2600 2600
  */
2601
-  function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2602
-    if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2603
-    $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2601
+  function setExrule($exruleset, $params = FALSE, $index = FALSE) {
2602
+    if (empty($exruleset)) if ($this->getConfig('allowEmpty')) $exruleset = null; else return FALSE;
2603
+    $this->_setMval($this->exrule, $this->_setRexrule($exruleset), $params, FALSE, $index);
2604 2604
     return TRUE;
2605 2605
   }
2606 2606
 /*********************************************************************************/
@@ -2615,47 +2615,47 @@  discard block
 block discarded – undo
2615 2615
  * @return string
2616 2616
  */
2617 2617
   function createFreebusy() {
2618
-    if( empty( $this->freebusy )) return FALSE;
2618
+    if (empty($this->freebusy)) return FALSE;
2619 2619
     $output = null;
2620
-    foreach( $this->freebusy as $freebusyPart ) {
2621
-      if( empty( $freebusyPart['value'] )) {
2622
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2620
+    foreach ($this->freebusy as $freebusyPart) {
2621
+      if (empty($freebusyPart['value'])) {
2622
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('FREEBUSY');
2623 2623
         continue;
2624 2624
       }
2625 2625
       $attributes = $content = null;
2626
-      if( isset( $freebusyPart['value']['fbtype'] )) {
2626
+      if (isset($freebusyPart['value']['fbtype'])) {
2627 2627
         $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2628
-        unset( $freebusyPart['value']['fbtype'] );
2629
-        $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2628
+        unset($freebusyPart['value']['fbtype']);
2629
+        $freebusyPart['value'] = array_values($freebusyPart['value']);
2630 2630
       }
2631 2631
       else
2632 2632
         $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2633
-      $attributes .= $this->_createParams( $freebusyPart['params'] );
2633
+      $attributes .= $this->_createParams($freebusyPart['params']);
2634 2634
       $fno = 1;
2635
-      $cnt = count( $freebusyPart['value']);
2636
-      foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) {
2637
-        $formatted   = $this->_format_date_time( $freebusyPeriod[0] );
2635
+      $cnt = count($freebusyPart['value']);
2636
+      foreach ($freebusyPart['value'] as $periodix => $freebusyPeriod) {
2637
+        $formatted = $this->_format_date_time($freebusyPeriod[0]);
2638 2638
         $content .= $formatted;
2639 2639
         $content .= '/';
2640
-        $cnt2 = count( $freebusyPeriod[1]);
2641
-        if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2640
+        $cnt2 = count($freebusyPeriod[1]);
2641
+        if (array_key_exists('year', $freebusyPeriod[1]))      // date-time
2642 2642
           $cnt2 = 7;
2643
-        elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2643
+        elseif (array_key_exists('week', $freebusyPeriod[1]))  // duration
2644 2644
           $cnt2 = 5;
2645
-        if(( 7 == $cnt2 )   &&    // period=  -> date-time
2646
-            isset( $freebusyPeriod[1]['year'] )  &&
2647
-            isset( $freebusyPeriod[1]['month'] ) &&
2648
-            isset( $freebusyPeriod[1]['day'] )) {
2649
-          $content .= $this->_format_date_time( $freebusyPeriod[1] );
2645
+        if ((7 == $cnt2) && // period=  -> date-time
2646
+            isset($freebusyPeriod[1]['year']) &&
2647
+            isset($freebusyPeriod[1]['month']) &&
2648
+            isset($freebusyPeriod[1]['day'])) {
2649
+          $content .= $this->_format_date_time($freebusyPeriod[1]);
2650 2650
         }
2651 2651
         else {                                  // period=  -> dur-time
2652
-          $content .= $this->_format_duration( $freebusyPeriod[1] );
2652
+          $content .= $this->_format_duration($freebusyPeriod[1]);
2653 2653
         }
2654
-        if( $fno < $cnt )
2654
+        if ($fno < $cnt)
2655 2655
           $content .= ',';
2656 2656
         $fno++;
2657 2657
       }
2658
-      $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
2658
+      $output .= $this->_createElement('FREEBUSY', $attributes, $content);
2659 2659
     }
2660 2660
     return $output;
2661 2661
   }
@@ -2670,52 +2670,52 @@  discard block
 block discarded – undo
2670 2670
  * @param integer $index, optional
2671 2671
  * @return bool
2672 2672
  */
2673
-  function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) {
2674
-    if( empty( $fbValues )) {
2675
-      if( $this->getConfig( 'allowEmpty' )) {
2676
-        $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2673
+  function setFreebusy($fbType, $fbValues, $params = FALSE, $index = FALSE) {
2674
+    if (empty($fbValues)) {
2675
+      if ($this->getConfig('allowEmpty')) {
2676
+        $this->_setMval($this->freebusy, null, $params, FALSE, $index);
2677 2677
         return TRUE;
2678 2678
       }
2679 2679
       else
2680 2680
         return FALSE;
2681 2681
     }
2682
-    $fbType = strtoupper( $fbType );
2683
-    if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2684
-       ( 'X-' != substr( $fbType, 0, 2 )))
2682
+    $fbType = strtoupper($fbType);
2683
+    if ((!in_array($fbType, array('FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE'))) &&
2684
+       ('X-' != substr($fbType, 0, 2)))
2685 2685
       $fbType = 'BUSY';
2686
-    $input = array( 'fbtype' => $fbType );
2687
-    foreach( $fbValues as $fbPeriod ) {   // periods => period
2686
+    $input = array('fbtype' => $fbType);
2687
+    foreach ($fbValues as $fbPeriod) {   // periods => period
2688 2688
       $freebusyPeriod = array();
2689
-      foreach( $fbPeriod as $fbMember ) { // pairs => singlepart
2689
+      foreach ($fbPeriod as $fbMember) { // pairs => singlepart
2690 2690
         $freebusyPairMember = array();
2691
-        if( is_array( $fbMember )) {
2692
-          if( $this->_isArrayDate( $fbMember )) { // date-time value
2693
-            $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2691
+        if (is_array($fbMember)) {
2692
+          if ($this->_isArrayDate($fbMember)) { // date-time value
2693
+            $freebusyPairMember       = $this->_date_time_array($fbMember, 7);
2694 2694
             $freebusyPairMember['tz'] = 'Z';
2695 2695
           }
2696
-          elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2697
-            $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2696
+          elseif ($this->_isArrayTimestampDate($fbMember)) { // timestamp value
2697
+            $freebusyPairMember       = $this->_timestamp2date($fbMember['timestamp'], 7);
2698 2698
             $freebusyPairMember['tz'] = 'Z';
2699 2699
           }
2700 2700
           else {                                         // array format duration
2701
-            $freebusyPairMember = $this->_duration_array( $fbMember );
2701
+            $freebusyPairMember = $this->_duration_array($fbMember);
2702 2702
           }
2703 2703
         }
2704
-        elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2705
-               ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2706
-          if( 'P' != $fbMember{0} )
2707
-            $fbmember = substr( $fbMember, 1 );
2708
-          $freebusyPairMember = $this->_duration_string( $fbMember );
2704
+        elseif ((3 <= strlen(trim($fbMember))) && // string format duration
2705
+               (in_array($fbMember{0}, array('P', '+', '-')))) {
2706
+          if ('P' != $fbMember{0} )
2707
+            $fbmember = substr($fbMember, 1);
2708
+          $freebusyPairMember = $this->_duration_string($fbMember);
2709 2709
         }
2710
-        elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2711
-          $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2710
+        elseif (8 <= strlen(trim($fbMember))) { // text date ex. 2006-08-03 10:12:18
2711
+          $freebusyPairMember       = $this->_date_time_string($fbMember, 7);
2712 2712
           $freebusyPairMember['tz'] = 'Z';
2713 2713
         }
2714 2714
         $freebusyPeriod[]   = $freebusyPairMember;
2715 2715
       }
2716 2716
       $input[]              = $freebusyPeriod;
2717 2717
     }
2718
-    $this->_setMval( $this->freebusy, $input, $params, FALSE, $index );
2718
+    $this->_setMval($this->freebusy, $input, $params, FALSE, $index);
2719 2719
     return TRUE;
2720 2720
   }
2721 2721
 /*********************************************************************************/
@@ -2730,15 +2730,15 @@  discard block
 block discarded – undo
2730 2730
  * @return string
2731 2731
  */
2732 2732
   function createGeo() {
2733
-    if( empty( $this->geo )) return FALSE;
2734
-    if( empty( $this->geo['value'] ))
2735
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
2736
-    $attributes = $this->_createParams( $this->geo['params'] );
2733
+    if (empty($this->geo)) return FALSE;
2734
+    if (empty($this->geo['value']))
2735
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('GEO') : FALSE;
2736
+    $attributes = $this->_createParams($this->geo['params']);
2737 2737
     $content    = null;
2738
-    $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
2738
+    $content   .= number_format((float) $this->geo['value']['latitude'], 6, '.', '');
2739 2739
     $content   .= ';';
2740
-    $content   .= number_format( (float) $this->geo['value']['longitude'], 6, '.', '');
2741
-    return $this->_createElement( 'GEO', $attributes, $content );
2740
+    $content   .= number_format((float) $this->geo['value']['longitude'], 6, '.', '');
2741
+    return $this->_createElement('GEO', $attributes, $content);
2742 2742
   }
2743 2743
 /**
2744 2744
  * set calendar component property geo
@@ -2750,15 +2750,15 @@  discard block
 block discarded – undo
2750 2750
  * @param array $params optional
2751 2751
  * @return bool
2752 2752
  */
2753
-  function setGeo( $latitude, $longitude, $params=FALSE ) {
2754
-    if( !empty( $latitude ) && !empty( $longitude )) {
2755
-      if( !is_array( $this->geo )) $this->geo = array();
2753
+  function setGeo($latitude, $longitude, $params = FALSE) {
2754
+    if (!empty($latitude) && !empty($longitude)) {
2755
+      if (!is_array($this->geo)) $this->geo = array();
2756 2756
       $this->geo['value']['latitude']  = $latitude;
2757 2757
       $this->geo['value']['longitude'] = $longitude;
2758
-      $this->geo['params'] = $this->_setParams( $params );
2758
+      $this->geo['params'] = $this->_setParams($params);
2759 2759
     }
2760
-    elseif( $this->getConfig( 'allowEmpty' ))
2761
-      $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2760
+    elseif ($this->getConfig('allowEmpty'))
2761
+      $this->geo = array('value' => null, 'params' => $this->_setParams($params));
2762 2762
     else
2763 2763
       return FALSE;
2764 2764
     return TRUE;
@@ -2775,10 +2775,10 @@  discard block
 block discarded – undo
2775 2775
  * @return string
2776 2776
  */
2777 2777
   function createLastModified() {
2778
-    if( empty( $this->lastmodified )) return FALSE;
2779
-    $attributes = $this->_createParams( $this->lastmodified['params'] );
2780
-    $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2781
-    return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
2778
+    if (empty($this->lastmodified)) return FALSE;
2779
+    $attributes = $this->_createParams($this->lastmodified['params']);
2780
+    $formatted  = $this->_format_date_time($this->lastmodified['value'], 7);
2781
+    return $this->_createElement('LAST-MODIFIED', $attributes, $formatted);
2782 2782
   }
2783 2783
 /**
2784 2784
  * set calendar component property completed
@@ -2794,10 +2794,10 @@  discard block
 block discarded – undo
2794 2794
  * @param array $params optional
2795 2795
  * @return boll
2796 2796
  */
2797
-  function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798
-    if( empty( $year ))
2799
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2800
-    $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2797
+  function setLastModified($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
2798
+    if (empty($year))
2799
+      $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y')));
2800
+    $this->lastmodified = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params);
2801 2801
     return TRUE;
2802 2802
   }
2803 2803
 /*********************************************************************************/
@@ -2812,12 +2812,12 @@  discard block
 block discarded – undo
2812 2812
  * @return string
2813 2813
  */
2814 2814
   function createLocation() {
2815
-    if( empty( $this->location )) return FALSE;
2816
-    if( empty( $this->location['value'] ))
2817
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
2818
-    $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2819
-    $content    = $this->_strrep( $this->location['value'] );
2820
-    return $this->_createElement( 'LOCATION', $attributes, $content );
2815
+    if (empty($this->location)) return FALSE;
2816
+    if (empty($this->location['value']))
2817
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('LOCATION') : FALSE;
2818
+    $attributes = $this->_createParams($this->location['params'], array('ALTREP', 'LANGUAGE'));
2819
+    $content    = $this->_strrep($this->location['value']);
2820
+    return $this->_createElement('LOCATION', $attributes, $content);
2821 2821
   }
2822 2822
 /**
2823 2823
  * set calendar component property location
@@ -2828,9 +2828,9 @@  discard block
 block discarded – undo
2828 2828
  * @param array params optional
2829 2829
  * @return bool
2830 2830
  */
2831
-  function setLocation( $value, $params=FALSE ) {
2832
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2833
-    $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2831
+  function setLocation($value, $params = FALSE) {
2832
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2833
+    $this->location = array('value' => $value, 'params' => $this->_setParams($params));
2834 2834
     return TRUE;
2835 2835
   }
2836 2836
 /*********************************************************************************/
@@ -2845,13 +2845,13 @@  discard block
 block discarded – undo
2845 2845
  * @return string
2846 2846
  */
2847 2847
   function createOrganizer() {
2848
-    if( empty( $this->organizer )) return FALSE;
2849
-    if( empty( $this->organizer['value'] ))
2850
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
2851
-    $attributes = $this->_createParams( $this->organizer['params']
2852
-                                      , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2848
+    if (empty($this->organizer)) return FALSE;
2849
+    if (empty($this->organizer['value']))
2850
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('ORGANIZER') : FALSE;
2851
+    $attributes = $this->_createParams($this->organizer['params']
2852
+                                      , array('CN', 'DIR', 'LANGUAGE', 'SENT-BY'));
2853 2853
     $content    = 'MAILTO:'.$this->organizer['value'];
2854
-    return $this->_createElement( 'ORGANIZER', $attributes, $content );
2854
+    return $this->_createElement('ORGANIZER', $attributes, $content);
2855 2855
   }
2856 2856
 /**
2857 2857
  * set calendar component property organizer
@@ -2862,14 +2862,14 @@  discard block
 block discarded – undo
2862 2862
  * @param array params optional
2863 2863
  * @return bool
2864 2864
  */
2865
-  function setOrganizer( $value, $params=FALSE ) {
2866
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2867
-    $value = str_replace ( 'MAILTO:', '', $value );
2868
-    $value = str_replace ( 'mailto:', '', $value );
2869
-    $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2870
-    if( isset( $this->organizer['params']['SENT-BY'] )) {
2871
-      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2872
-        $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
2865
+  function setOrganizer($value, $params = FALSE) {
2866
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2867
+    $value = str_replace('MAILTO:', '', $value);
2868
+    $value = str_replace('mailto:', '', $value);
2869
+    $this->organizer = array('value' => $value, 'params' => $this->_setParams($params));
2870
+    if (isset($this->organizer['params']['SENT-BY'])) {
2871
+      if ('MAILTO' == strtoupper(substr($this->organizer['params']['SENT-BY'], 0, 6)))
2872
+        $this->organizer['params']['SENT-BY'] = substr($this->organizer['params']['SENT-BY'], 7);
2873 2873
     }
2874 2874
     return TRUE;
2875 2875
   }
@@ -2885,11 +2885,11 @@  discard block
 block discarded – undo
2885 2885
  * @return string
2886 2886
  */
2887 2887
   function createPercentComplete() {
2888
-    if( empty( $this->percentcomplete )) return FALSE;
2889
-    if( empty( $this->percentcomplete['value'] ))
2890
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
2891
-    $attributes = $this->_createParams( $this->percentcomplete['params'] );
2892
-    return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2888
+    if (empty($this->percentcomplete)) return FALSE;
2889
+    if (empty($this->percentcomplete['value']))
2890
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('PERCENT-COMPLETE') : FALSE;
2891
+    $attributes = $this->_createParams($this->percentcomplete['params']);
2892
+    return $this->_createElement('PERCENT-COMPLETE', $attributes, $this->percentcomplete['value']);
2893 2893
   }
2894 2894
 /**
2895 2895
  * set calendar component property percent-complete
@@ -2900,9 +2900,9 @@  discard block
 block discarded – undo
2900 2900
  * @param array $params optional
2901 2901
  * @return bool
2902 2902
  */
2903
-  function setPercentComplete( $value, $params=FALSE ) {
2904
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2905
-    $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2903
+  function setPercentComplete($value, $params = FALSE) {
2904
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2905
+    $this->percentcomplete = array('value' => $value, 'params' => $this->_setParams($params));
2906 2906
     return TRUE;
2907 2907
   }
2908 2908
 /*********************************************************************************/
@@ -2917,11 +2917,11 @@  discard block
 block discarded – undo
2917 2917
  * @return string
2918 2918
  */
2919 2919
   function createPriority() {
2920
-    if( empty( $this->priority )) return FALSE;
2921
-    if( empty( $this->priority['value'] ))
2922
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
2923
-    $attributes = $this->_createParams( $this->priority['params'] );
2924
-    return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2920
+    if (empty($this->priority)) return FALSE;
2921
+    if (empty($this->priority['value']))
2922
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('PRIORITY') : FALSE;
2923
+    $attributes = $this->_createParams($this->priority['params']);
2924
+    return $this->_createElement('PRIORITY', $attributes, $this->priority['value']);
2925 2925
   }
2926 2926
 /**
2927 2927
  * set calendar component property priority
@@ -2932,9 +2932,9 @@  discard block
 block discarded – undo
2932 2932
  * @param array $params optional
2933 2933
  * @return bool
2934 2934
  */
2935
-  function setPriority( $value, $params=FALSE  ) {
2936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2937
-    $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2935
+  function setPriority($value, $params = FALSE) {
2936
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
2937
+    $this->priority = array('value' => $value, 'params' => $this->_setParams($params));
2938 2938
     return TRUE;
2939 2939
   }
2940 2940
 /*********************************************************************************/
@@ -2949,91 +2949,91 @@  discard block
 block discarded – undo
2949 2949
  * @return string
2950 2950
  */
2951 2951
   function createRdate() {
2952
-    if( empty( $this->rdate )) return FALSE;
2953
-    $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2952
+    if (empty($this->rdate)) return FALSE;
2953
+    $utctime = (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE;
2954 2954
     $output = null;
2955
-    if( $utctime  )
2956
-      unset( $this->rdate['params']['TZID'] );
2957
-    foreach( $this->rdate as $theRdate ) {
2958
-      if( empty( $theRdate['value'] )) {
2959
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
2955
+    if ($utctime)
2956
+      unset($this->rdate['params']['TZID']);
2957
+    foreach ($this->rdate as $theRdate) {
2958
+      if (empty($theRdate['value'])) {
2959
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RDATE');
2960 2960
         continue;
2961 2961
       }
2962
-      if( $utctime  )
2963
-        unset( $theRdate['params']['TZID'] );
2964
-      $attributes = $this->_createParams( $theRdate['params'] );
2965
-      $cnt = count( $theRdate['value'] );
2962
+      if ($utctime)
2963
+        unset($theRdate['params']['TZID']);
2964
+      $attributes = $this->_createParams($theRdate['params']);
2965
+      $cnt = count($theRdate['value']);
2966 2966
       $content = null;
2967 2967
       $rno = 1;
2968
-      foreach( $theRdate['value'] as $rpix => $rdatePart ) {
2968
+      foreach ($theRdate['value'] as $rpix => $rdatePart) {
2969 2969
         $contentPart = null;
2970
-        if( is_array( $rdatePart ) &&
2971
-            isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2972
-          if( $utctime )
2973
-            unset( $rdatePart[0]['tz'] );
2974
-          $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2975
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
2976
-            $formatted = str_replace( 'Z', '', $formatted);
2977
-          if( 0 < $rpix ) {
2978
-            if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2979
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2970
+        if (is_array($rdatePart) &&
2971
+            isset($theRdate['params']['VALUE']) && ('PERIOD' == $theRdate['params']['VALUE'])) { // PERIOD
2972
+          if ($utctime)
2973
+            unset($rdatePart[0]['tz']);
2974
+          $formatted = $this->_format_date_time($rdatePart[0]); // PERIOD part 1
2975
+          if ($utctime || !empty($theRdate['params']['TZID']))
2976
+            $formatted = str_replace('Z', '', $formatted);
2977
+          if (0 < $rpix) {
2978
+            if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) {
2979
+              if ('Z' != substr($formatted, -1)) $formatted .= 'Z';
2980 2980
             }
2981 2981
             else
2982
-              $formatted = str_replace( 'Z', '', $formatted );
2982
+              $formatted = str_replace('Z', '', $formatted);
2983 2983
           }
2984 2984
           $contentPart .= $formatted;
2985 2985
           $contentPart .= '/';
2986
-          $cnt2 = count( $rdatePart[1]);
2987
-          if( array_key_exists( 'year', $rdatePart[1] )) {
2988
-            if( array_key_exists( 'hour', $rdatePart[1] ))
2989
-              $cnt2 = 7;                                      // date-time
2986
+          $cnt2 = count($rdatePart[1]);
2987
+          if (array_key_exists('year', $rdatePart[1])) {
2988
+            if (array_key_exists('hour', $rdatePart[1]))
2989
+              $cnt2 = 7; // date-time
2990 2990
             else
2991
-              $cnt2 = 3;                                      // date
2991
+              $cnt2 = 3; // date
2992 2992
           }
2993
-          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
2993
+          elseif (array_key_exists('week', $rdatePart[1]))  // duration
2994 2994
             $cnt2 = 5;
2995
-          if(( 7 == $cnt2 )   &&    // period=  -> date-time
2996
-              isset( $rdatePart[1]['year'] )  &&
2997
-              isset( $rdatePart[1]['month'] ) &&
2998
-              isset( $rdatePart[1]['day'] )) {
2999
-            if( $utctime )
3000
-              unset( $rdatePart[1]['tz'] );
3001
-            $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3002
-            if( $utctime || !empty( $theRdate['params']['TZID'] ))
3003
-              $formatted = str_replace( 'Z', '', $formatted);
3004
-            if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3005
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2995
+          if ((7 == $cnt2) && // period=  -> date-time
2996
+              isset($rdatePart[1]['year']) &&
2997
+              isset($rdatePart[1]['month']) &&
2998
+              isset($rdatePart[1]['day'])) {
2999
+            if ($utctime)
3000
+              unset($rdatePart[1]['tz']);
3001
+            $formatted = $this->_format_date_time($rdatePart[1]); // PERIOD part 2
3002
+            if ($utctime || !empty($theRdate['params']['TZID']))
3003
+              $formatted = str_replace('Z', '', $formatted);
3004
+            if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) {
3005
+              if ('Z' != substr($formatted, -1)) $formatted .= 'Z';
3006 3006
             }
3007 3007
             else
3008
-              $formatted = str_replace( 'Z', '', $formatted );
3008
+              $formatted = str_replace('Z', '', $formatted);
3009 3009
            $contentPart .= $formatted;
3010 3010
           }
3011 3011
           else {                                  // period=  -> dur-time
3012
-            $contentPart .= $this->_format_duration( $rdatePart[1] );
3012
+            $contentPart .= $this->_format_duration($rdatePart[1]);
3013 3013
           }
3014 3014
         } // PERIOD end
3015 3015
         else { // SINGLE date start
3016
-          if( $utctime )
3017
-            unset( $rdatePart['tz'] );
3018
-          $formatted = $this->_format_date_time( $rdatePart);
3019
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
3020
-            $formatted = str_replace( 'Z', '', $formatted);
3021
-          if( !$utctime && ( 0 < $rpix )) {
3022
-            if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3023
-              if( 'Z' != substr( $formatted, -1 ))
3016
+          if ($utctime)
3017
+            unset($rdatePart['tz']);
3018
+          $formatted = $this->_format_date_time($rdatePart);
3019
+          if ($utctime || !empty($theRdate['params']['TZID']))
3020
+            $formatted = str_replace('Z', '', $formatted);
3021
+          if (!$utctime && (0 < $rpix)) {
3022
+            if (!empty($theRdate['value'][0]['tz']) && $this->_isOffset($theRdate['value'][0]['tz'])) {
3023
+              if ('Z' != substr($formatted, -1))
3024 3024
                 $formatted .= 'Z';
3025 3025
             }
3026 3026
             else
3027
-              $formatted = str_replace( 'Z', '', $formatted );
3027
+              $formatted = str_replace('Z', '', $formatted);
3028 3028
           }
3029 3029
           $contentPart .= $formatted;
3030 3030
         }
3031 3031
         $content .= $contentPart;
3032
-        if( $rno < $cnt )
3032
+        if ($rno < $cnt)
3033 3033
           $content .= ',';
3034 3034
         $rno++;
3035 3035
       }
3036
-      $output    .= $this->_createElement( 'RDATE', $attributes, $content );
3036
+      $output .= $this->_createElement('RDATE', $attributes, $content);
3037 3037
     }
3038 3038
     return $output;
3039 3039
   }
@@ -3047,93 +3047,93 @@  discard block
 block discarded – undo
3047 3047
  * @param integer $index, optional
3048 3048
  * @return bool
3049 3049
  */
3050
-  function setRdate( $rdates, $params=FALSE, $index=FALSE ) {
3051
-    if( empty( $rdates )) {
3052
-      if( $this->getConfig( 'allowEmpty' )) {
3053
-        $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3050
+  function setRdate($rdates, $params = FALSE, $index = FALSE) {
3051
+    if (empty($rdates)) {
3052
+      if ($this->getConfig('allowEmpty')) {
3053
+        $this->_setMval($this->rdate, null, $params, FALSE, $index);
3054 3054
         return TRUE;
3055 3055
       }
3056 3056
       else
3057 3057
         return FALSE;
3058 3058
     }
3059
-    $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3060
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3061
-      unset( $input['params']['TZID'] );
3059
+    $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME')));
3060
+    if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) {
3061
+      unset($input['params']['TZID']);
3062 3062
       $input['params']['VALUE'] = 'DATE-TIME';
3063 3063
     }
3064 3064
             /*  check if PERIOD, if not set */
3065
-    if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) &&
3066
-          isset( $rdates[0] )    && is_array( $rdates[0] ) && ( 2 == count( $rdates[0] )) &&
3067
-          isset( $rdates[0][0] ) &&    isset( $rdates[0][1] ) && !isset( $rdates[0]['timestamp'] ) &&
3068
-    (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) ||
3069
-                                      $this->_isArrayDate( $rdates[0][0] ))) ||
3070
-                                    ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3071
-     ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3065
+    if ((!isset($input['params']['VALUE']) || !in_array($input['params']['VALUE'], array('DATE', 'PERIOD'))) &&
3066
+          isset($rdates[0]) && is_array($rdates[0]) && (2 == count($rdates[0])) &&
3067
+          isset($rdates[0][0]) && isset($rdates[0][1]) && !isset($rdates[0]['timestamp']) &&
3068
+    ((is_array($rdates[0][0]) && (isset($rdates[0][0]['timestamp']) ||
3069
+                                      $this->_isArrayDate($rdates[0][0]))) ||
3070
+                                    (is_string($rdates[0][0]) && (8 <= strlen(trim($rdates[0][0]))))) &&
3071
+     (is_array($rdates[0][1]) || (is_string($rdates[0][1]) && (3 <= strlen(trim($rdates[0][1]))))))
3072 3072
       $input['params']['VALUE'] = 'PERIOD';
3073 3073
             /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3074
-    $date  = reset( $rdates );
3075
-    if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3076
-      $date  = reset( $date );
3077
-    $this->_chkdatecfg( $date, $parno, $input['params'] );
3078
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3079
-      unset( $input['params']['TZID'] );
3080
-    $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3081
-    foreach( $rdates as $rpix => $theRdate ) {
3074
+    $date = reset($rdates);
3075
+    if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) // PERIOD
3076
+      $date = reset($date);
3077
+    $this->_chkdatecfg($date, $parno, $input['params']);
3078
+    if (in_array($this->objName, array('vtimezone', 'standard', 'daylight')))
3079
+      unset($input['params']['TZID']);
3080
+    $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default
3081
+    foreach ($rdates as $rpix => $theRdate) {
3082 3082
       $inputa = null;
3083
-      if( is_array( $theRdate )) {
3084
-        if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3085
-          foreach( $theRdate as $rix => $rPeriod ) {
3086
-            if( is_array( $rPeriod )) {
3087
-              if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3088
-                $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3089
-              elseif( $this->_isArrayDate( $rPeriod ))
3090
-                $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3091
-              elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3092
-                $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3083
+      if (is_array($theRdate)) {
3084
+        if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) { // PERIOD
3085
+          foreach ($theRdate as $rix => $rPeriod) {
3086
+            if (is_array($rPeriod)) {
3087
+              if ($this->_isArrayTimestampDate($rPeriod))      // timestamp
3088
+                $inputab  = (isset($rPeriod['tz'])) ? $this->_timestamp2date($rPeriod, $parno) : $this->_timestamp2date($rPeriod, 6);
3089
+              elseif ($this->_isArrayDate($rPeriod))
3090
+                $inputab  = (3 < count($rPeriod)) ? $this->_date_time_array($rPeriod, $parno) : $this->_date_time_array($rPeriod, 6);
3091
+              elseif ((1 == count($rPeriod)) && (8 <= strlen(reset($rPeriod))))  // text-date
3092
+                $inputab  = $this->_date_time_string(reset($rPeriod), $parno);
3093 3093
               else                                               // array format duration
3094
-                $inputab  = $this->_duration_array( $rPeriod );
3094
+                $inputab  = $this->_duration_array($rPeriod);
3095 3095
             }
3096
-            elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3097
-                   ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3098
-              if( 'P' != $rPeriod{0} )
3099
-                $rPeriod  = substr( $rPeriod, 1 );
3100
-              $inputab    = $this->_duration_string( $rPeriod );
3096
+            elseif ((3 <= strlen(trim($rPeriod))) && // string format duration
3097
+                   (in_array($rPeriod{0}, array('P', '+', '-')))) {
3098
+              if ('P' != $rPeriod{0} )
3099
+                $rPeriod  = substr($rPeriod, 1);
3100
+              $inputab    = $this->_duration_string($rPeriod);
3101 3101
             }
3102
-            elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3103
-              $inputab    = $this->_date_time_string( $rPeriod, $parno );
3104
-            if(  isset( $input['params']['TZID'] ) ||
3105
-               ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3106
-               ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3107
-               ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3108
-              unset( $inputab['tz'] );
3109
-            $inputa[]     = $inputab;
3102
+            elseif (8 <= strlen(trim($rPeriod)))              // text date ex. 2006-08-03 10:12:18
3103
+              $inputab    = $this->_date_time_string($rPeriod, $parno);
3104
+            if (isset($input['params']['TZID']) ||
3105
+               (isset($inputab['tz']) && !$this->_isOffset($inputab['tz'])) ||
3106
+               (isset($inputa[0]) && (!isset($inputa[0]['tz']))) ||
3107
+               (isset($inputa[0]['tz']) && !$this->_isOffset($inputa[0]['tz'])))
3108
+              unset($inputab['tz']);
3109
+            $inputa[] = $inputab;
3110 3110
           }
3111 3111
         } // PERIOD end
3112
-        elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3113
-          $inputa = $this->_timestamp2date( $theRdate, $parno );
3112
+        elseif ($this->_isArrayTimestampDate($theRdate))      // timestamp
3113
+          $inputa = $this->_timestamp2date($theRdate, $parno);
3114 3114
         else                                                     // date[-time]
3115
-          $inputa = $this->_date_time_array( $theRdate, $parno );
3115
+          $inputa = $this->_date_time_array($theRdate, $parno);
3116 3116
       }
3117
-      elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3118
-        $inputa       = $this->_date_time_string( $theRdate, $parno );
3119
-      if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3120
-        if( 3 == $parno )
3121
-          unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3122
-        elseif( isset( $inputa['tz'] ))
3117
+      elseif (8 <= strlen(trim($theRdate)))                   // text date ex. 2006-08-03 10:12:18
3118
+        $inputa = $this->_date_time_string($theRdate, $parno);
3119
+      if (!isset($input['params']['VALUE']) || ('PERIOD' != $input['params']['VALUE'])) { // no PERIOD
3120
+        if (3 == $parno)
3121
+          unset($inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz']);
3122
+        elseif (isset($inputa['tz']))
3123 3123
           $inputa['tz'] = (string) $inputa['tz'];
3124
-        if(  isset( $input['params']['TZID'] ) ||
3125
-           ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3126
-           ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3127
-           ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3128
-          unset( $inputa['tz'] );
3124
+        if (isset($input['params']['TZID']) ||
3125
+           (isset($inputa['tz']) && !$this->_isOffset($inputa['tz'])) ||
3126
+           (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) ||
3127
+           (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz'])))
3128
+          unset($inputa['tz']);
3129 3129
       }
3130 3130
       $input['value'][] = $inputa;
3131 3131
     }
3132
-    if( 3 == $parno ) {
3132
+    if (3 == $parno) {
3133 3133
       $input['params']['VALUE'] = 'DATE';
3134
-      unset( $input['params']['TZID'] );
3134
+      unset($input['params']['TZID']);
3135 3135
     }
3136
-    $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index );
3136
+    $this->_setMval($this->rdate, $input['value'], $input['params'], FALSE, $index);
3137 3137
     return TRUE;
3138 3138
   }
3139 3139
 /*********************************************************************************/
@@ -3148,12 +3148,12 @@  discard block
 block discarded – undo
3148 3148
  * @return string
3149 3149
  */
3150 3150
   function createRecurrenceid() {
3151
-    if( empty( $this->recurrenceid )) return FALSE;
3152
-    if( empty( $this->recurrenceid['value'] ))
3153
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3154
-    $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3155
-    $attributes = $this->_createParams( $this->recurrenceid['params'] );
3156
-    return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
3151
+    if (empty($this->recurrenceid)) return FALSE;
3152
+    if (empty($this->recurrenceid['value']))
3153
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('RECURRENCE-ID') : FALSE;
3154
+    $formatted  = $this->_format_date_time($this->recurrenceid['value']);
3155
+    $attributes = $this->_createParams($this->recurrenceid['params']);
3156
+    return $this->_createElement('RECURRENCE-ID', $attributes, $formatted);
3157 3157
   }
3158 3158
 /**
3159 3159
  * set calendar component property recurrence-id
@@ -3169,16 +3169,16 @@  discard block
 block discarded – undo
3169 3169
  * @param array $params optional
3170 3170
  * @return bool
3171 3171
  */
3172
-  function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
3173
-    if( empty( $year )) {
3174
-      if( $this->getConfig( 'allowEmpty' )) {
3175
-        $this->recurrenceid = array( 'value' => null, 'params' => null );
3172
+  function setRecurrenceid($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) {
3173
+    if (empty($year)) {
3174
+      if ($this->getConfig('allowEmpty')) {
3175
+        $this->recurrenceid = array('value' => null, 'params' => null);
3176 3176
         return TRUE;
3177 3177
       }
3178 3178
       else
3179 3179
         return FALSE;
3180 3180
     }
3181
-    $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3181
+    $this->recurrenceid = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params);
3182 3182
     return TRUE;
3183 3183
   }
3184 3184
 /*********************************************************************************/
@@ -3193,18 +3193,18 @@  discard block
 block discarded – undo
3193 3193
  * @return string
3194 3194
  */
3195 3195
   function createRelatedTo() {
3196
-    if( empty( $this->relatedto )) return FALSE;
3196
+    if (empty($this->relatedto)) return FALSE;
3197 3197
     $output = null;
3198
-    foreach( $this->relatedto as $relation ) {
3199
-      if( empty( $relation['value'] )) {
3200
-        if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3198
+    foreach ($this->relatedto as $relation) {
3199
+      if (empty($relation['value'])) {
3200
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RELATED-TO', $this->_createParams($relation['params']));
3201 3201
         continue;
3202 3202
       }
3203
-      $attributes = $this->_createParams( $relation['params'] );
3204
-      $content    = ( 'xcal' != $this->format ) ? '<' : '';
3205
-      $content   .= $this->_strrep( $relation['value'] );
3206
-      $content   .= ( 'xcal' != $this->format ) ? '>' : '';
3207
-      $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
3203
+      $attributes = $this->_createParams($relation['params']);
3204
+      $content    = ('xcal' != $this->format) ? '<' : '';
3205
+      $content   .= $this->_strrep($relation['value']);
3206
+      $content   .= ('xcal' != $this->format) ? '>' : '';
3207
+      $output    .= $this->_createElement('RELATED-TO', $attributes, $content);
3208 3208
     }
3209 3209
     return $output;
3210 3210
   }
@@ -3218,12 +3218,12 @@  discard block
 block discarded – undo
3218 3218
  * @param index $index, optional
3219 3219
  * @return bool
3220 3220
  */
3221
-  function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3222
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3223
-    if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3224
-      $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3225
-    $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3226
-    $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3221
+  function setRelatedTo($value, $params = FALSE, $index = FALSE) {
3222
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3223
+    if (('<' == substr($value, 0, 1)) && ('>' == substr($value, -1)))
3224
+      $value = substr($value, 1, (strlen($value) - 2));
3225
+    $this->_existRem($params, 'RELTYPE', 'PARENT', TRUE); // remove default
3226
+    $this->_setMval($this->relatedto, $value, $params, FALSE, $index);
3227 3227
     return TRUE;
3228 3228
   }
3229 3229
 /*********************************************************************************/
@@ -3238,11 +3238,11 @@  discard block
 block discarded – undo
3238 3238
  * @return string
3239 3239
  */
3240 3240
   function createRepeat() {
3241
-    if( empty( $this->repeat )) return FALSE;
3242
-    if( empty( $this->repeat['value'] ))
3243
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3244
-    $attributes = $this->_createParams( $this->repeat['params'] );
3245
-    return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3241
+    if (empty($this->repeat)) return FALSE;
3242
+    if (empty($this->repeat['value']))
3243
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('REPEAT') : FALSE;
3244
+    $attributes = $this->_createParams($this->repeat['params']);
3245
+    return $this->_createElement('REPEAT', $attributes, $this->repeat['value']);
3246 3246
   }
3247 3247
 /**
3248 3248
  * set calendar component property transp
@@ -3253,9 +3253,9 @@  discard block
 block discarded – undo
3253 3253
  * @param array $params optional
3254 3254
  * @return void
3255 3255
  */
3256
-  function setRepeat( $value, $params=FALSE ) {
3257
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3258
-    $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3256
+  function setRepeat($value, $params = FALSE) {
3257
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3258
+    $this->repeat = array('value' => $value, 'params' => $this->_setParams($params));
3259 3259
     return TRUE;
3260 3260
   }
3261 3261
 /*********************************************************************************/
@@ -3269,19 +3269,19 @@  discard block
 block discarded – undo
3269 3269
  * @return string
3270 3270
  */
3271 3271
   function createRequestStatus() {
3272
-    if( empty( $this->requeststatus )) return FALSE;
3272
+    if (empty($this->requeststatus)) return FALSE;
3273 3273
     $output = null;
3274
-    foreach( $this->requeststatus as $rstat ) {
3275
-      if( empty( $rstat['value']['statcode'] )) {
3276
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3274
+    foreach ($this->requeststatus as $rstat) {
3275
+      if (empty($rstat['value']['statcode'])) {
3276
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('REQUEST-STATUS');
3277 3277
         continue;
3278 3278
       }
3279
-      $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3280
-      $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3281
-      $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3282
-      if( isset( $rstat['value']['extdata'] ))
3283
-        $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3284
-      $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3279
+      $attributes  = $this->_createParams($rstat['params'], array('LANGUAGE'));
3280
+      $content     = number_format((float) $rstat['value']['statcode'], 2, '.', '');
3281
+      $content    .= ';'.$this->_strrep($rstat['value']['text']);
3282
+      if (isset($rstat['value']['extdata']))
3283
+        $content  .= ';'.$this->_strrep($rstat['value']['extdata']);
3284
+      $output     .= $this->_createElement('REQUEST-STATUS', $attributes, $content);
3285 3285
     }
3286 3286
     return $output;
3287 3287
   }
@@ -3297,12 +3297,12 @@  discard block
 block discarded – undo
3297 3297
  * @param integer $index, optional
3298 3298
  * @return bool
3299 3299
  */
3300
-  function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3301
-    if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3302
-    $input              = array( 'statcode' => $statcode, 'text' => $text );
3303
-    if( $extdata )
3300
+  function setRequestStatus($statcode, $text, $extdata = FALSE, $params = FALSE, $index = FALSE) {
3301
+    if (empty($statcode) || empty($text)) if ($this->getConfig('allowEmpty')) $statcode = $text = null; else return FALSE;
3302
+    $input              = array('statcode' => $statcode, 'text' => $text);
3303
+    if ($extdata)
3304 3304
       $input['extdata'] = $extdata;
3305
-    $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3305
+    $this->_setMval($this->requeststatus, $input, $params, FALSE, $index);
3306 3306
     return TRUE;
3307 3307
   }
3308 3308
 /*********************************************************************************/
@@ -3317,22 +3317,22 @@  discard block
 block discarded – undo
3317 3317
  * @return string
3318 3318
  */
3319 3319
   function createResources() {
3320
-    if( empty( $this->resources )) return FALSE;
3320
+    if (empty($this->resources)) return FALSE;
3321 3321
     $output = null;
3322
-    foreach( $this->resources as $resource ) {
3323
-      if( empty( $resource['value'] )) {
3324
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3322
+    foreach ($this->resources as $resource) {
3323
+      if (empty($resource['value'])) {
3324
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RESOURCES');
3325 3325
         continue;
3326 3326
       }
3327
-      $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3328
-      if( is_array( $resource['value'] )) {
3329
-        foreach( $resource['value'] as $rix => $resourcePart )
3330
-          $resource['value'][$rix] = $this->_strrep( $resourcePart );
3331
-        $content   = implode( ',', $resource['value'] );
3327
+      $attributes = $this->_createParams($resource['params'], array('ALTREP', 'LANGUAGE'));
3328
+      if (is_array($resource['value'])) {
3329
+        foreach ($resource['value'] as $rix => $resourcePart)
3330
+          $resource['value'][$rix] = $this->_strrep($resourcePart);
3331
+        $content   = implode(',', $resource['value']);
3332 3332
       }
3333 3333
       else
3334
-        $content   = $this->_strrep( $resource['value'] );
3335
-      $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3334
+        $content   = $this->_strrep($resource['value']);
3335
+      $output     .= $this->_createElement('RESOURCES', $attributes, $content);
3336 3336
     }
3337 3337
     return $output;
3338 3338
   }
@@ -3346,9 +3346,9 @@  discard block
 block discarded – undo
3346 3346
  * @param integer $index, optional
3347 3347
  * @return bool
3348 3348
  */
3349
-  function setResources( $value, $params=FALSE, $index=FALSE ) {
3350
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3351
-    $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3349
+  function setResources($value, $params = FALSE, $index = FALSE) {
3350
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3351
+    $this->_setMval($this->resources, $value, $params, FALSE, $index);
3352 3352
     return TRUE;
3353 3353
   }
3354 3354
 /*********************************************************************************/
@@ -3363,8 +3363,8 @@  discard block
 block discarded – undo
3363 3363
  * @return string
3364 3364
  */
3365 3365
   function createRrule() {
3366
-    if( empty( $this->rrule )) return FALSE;
3367
-    return $this->_format_recur( 'RRULE', $this->rrule );
3366
+    if (empty($this->rrule)) return FALSE;
3367
+    return $this->_format_recur('RRULE', $this->rrule);
3368 3368
   }
3369 3369
 /**
3370 3370
  * set calendar component property rrule
@@ -3376,9 +3376,9 @@  discard block
 block discarded – undo
3376 3376
  * @param integer $index, optional
3377 3377
  * @return void
3378 3378
  */
3379
-  function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380
-    if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3381
-    $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3379
+  function setRrule($rruleset, $params = FALSE, $index = FALSE) {
3380
+    if (empty($rruleset)) if ($this->getConfig('allowEmpty')) $rruleset = null; else return FALSE;
3381
+    $this->_setMval($this->rrule, $this->_setRexrule($rruleset), $params, FALSE, $index);
3382 3382
     return TRUE;
3383 3383
   }
3384 3384
 /*********************************************************************************/
@@ -3392,11 +3392,11 @@  discard block
 block discarded – undo
3392 3392
  * @return string
3393 3393
  */
3394 3394
   function createSequence() {
3395
-    if( empty( $this->sequence )) return FALSE;
3396
-    if( empty( $this->sequence['value'] ))
3397
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3398
-    $attributes = $this->_createParams( $this->sequence['params'] );
3399
-    return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3395
+    if (empty($this->sequence)) return FALSE;
3396
+    if (empty($this->sequence['value']))
3397
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('SEQUENCE') : FALSE;
3398
+    $attributes = $this->_createParams($this->sequence['params']);
3399
+    return $this->_createElement('SEQUENCE', $attributes, $this->sequence['value']);
3400 3400
   }
3401 3401
 /**
3402 3402
  * set calendar component property sequence
@@ -3406,10 +3406,10 @@  discard block
 block discarded – undo
3406 3406
  * @param array $params optional
3407 3407
  * @return bool
3408 3408
  */
3409
-  function setSequence( $value=FALSE, $params=FALSE ) {
3410
-    if( empty( $value ))
3411
-      $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3412
-    $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3409
+  function setSequence($value = FALSE, $params = FALSE) {
3410
+    if (empty($value))
3411
+      $value = (isset($this->sequence['value']) && (0 < $this->sequence['value'])) ? $this->sequence['value'] + 1 : 1;
3412
+    $this->sequence = array('value' => $value, 'params' => $this->_setParams($params));
3413 3413
     return TRUE;
3414 3414
   }
3415 3415
 /*********************************************************************************/
@@ -3424,11 +3424,11 @@  discard block
 block discarded – undo
3424 3424
  * @return string
3425 3425
  */
3426 3426
   function createStatus() {
3427
-    if( empty( $this->status )) return FALSE;
3428
-    if( empty( $this->status['value'] ))
3429
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3430
-    $attributes = $this->_createParams( $this->status['params'] );
3431
-    return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3427
+    if (empty($this->status)) return FALSE;
3428
+    if (empty($this->status['value']))
3429
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('STATUS') : FALSE;
3430
+    $attributes = $this->_createParams($this->status['params']);
3431
+    return $this->_createElement('STATUS', $attributes, $this->status['value']);
3432 3432
   }
3433 3433
 /**
3434 3434
  * set calendar component property status
@@ -3439,9 +3439,9 @@  discard block
 block discarded – undo
3439 3439
  * @param array $params optional
3440 3440
  * @return bool
3441 3441
  */
3442
-  function setStatus( $value, $params=FALSE ) {
3443
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3444
-    $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3442
+  function setStatus($value, $params = FALSE) {
3443
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3444
+    $this->status = array('value' => $value, 'params' => $this->_setParams($params));
3445 3445
     return TRUE;
3446 3446
   }
3447 3447
 /*********************************************************************************/
@@ -3456,12 +3456,12 @@  discard block
 block discarded – undo
3456 3456
  * @return string
3457 3457
  */
3458 3458
   function createSummary() {
3459
-    if( empty( $this->summary )) return FALSE;
3460
-    if( empty( $this->summary['value'] ))
3461
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3462
-    $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3463
-    $content    = $this->_strrep( $this->summary['value'] );
3464
-    return $this->_createElement( 'SUMMARY', $attributes, $content );
3459
+    if (empty($this->summary)) return FALSE;
3460
+    if (empty($this->summary['value']))
3461
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('SUMMARY') : FALSE;
3462
+    $attributes = $this->_createParams($this->summary['params'], array('ALTREP', 'LANGUAGE'));
3463
+    $content    = $this->_strrep($this->summary['value']);
3464
+    return $this->_createElement('SUMMARY', $attributes, $content);
3465 3465
   }
3466 3466
 /**
3467 3467
  * set calendar component property summary
@@ -3472,9 +3472,9 @@  discard block
 block discarded – undo
3472 3472
  * @param string $params optional
3473 3473
  * @return bool
3474 3474
  */
3475
-  function setSummary( $value, $params=FALSE ) {
3476
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3477
-    $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3475
+  function setSummary($value, $params = FALSE) {
3476
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3477
+    $this->summary = array('value' => $value, 'params' => $this->_setParams($params));
3478 3478
     return TRUE;
3479 3479
   }
3480 3480
 /*********************************************************************************/
@@ -3489,11 +3489,11 @@  discard block
 block discarded – undo
3489 3489
  * @return string
3490 3490
  */
3491 3491
   function createTransp() {
3492
-    if( empty( $this->transp )) return FALSE;
3493
-    if( empty( $this->transp['value'] ))
3494
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3495
-    $attributes = $this->_createParams( $this->transp['params'] );
3496
-    return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3492
+    if (empty($this->transp)) return FALSE;
3493
+    if (empty($this->transp['value']))
3494
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRANSP') : FALSE;
3495
+    $attributes = $this->_createParams($this->transp['params']);
3496
+    return $this->_createElement('TRANSP', $attributes, $this->transp['value']);
3497 3497
   }
3498 3498
 /**
3499 3499
  * set calendar component property transp
@@ -3504,9 +3504,9 @@  discard block
 block discarded – undo
3504 3504
  * @param string $params optional
3505 3505
  * @return bool
3506 3506
  */
3507
-  function setTransp( $value, $params=FALSE ) {
3508
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3509
-    $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3507
+  function setTransp($value, $params = FALSE) {
3508
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3509
+    $this->transp = array('value' => $value, 'params' => $this->_setParams($params));
3510 3510
     return TRUE;
3511 3511
   }
3512 3512
 /*********************************************************************************/
@@ -3521,23 +3521,23 @@  discard block
 block discarded – undo
3521 3521
  * @return string
3522 3522
  */
3523 3523
   function createTrigger() {
3524
-    if( empty( $this->trigger )) return FALSE;
3525
-    if( empty( $this->trigger['value'] ))
3526
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3524
+    if (empty($this->trigger)) return FALSE;
3525
+    if (empty($this->trigger['value']))
3526
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRIGGER') : FALSE;
3527 3527
     $content = $attributes = null;
3528
-    if( isset( $this->trigger['value']['year'] )   &&
3529
-        isset( $this->trigger['value']['month'] )  &&
3530
-        isset( $this->trigger['value']['day'] ))
3531
-      $content      .= $this->_format_date_time( $this->trigger['value'] );
3528
+    if (isset($this->trigger['value']['year']) &&
3529
+        isset($this->trigger['value']['month']) &&
3530
+        isset($this->trigger['value']['day']))
3531
+      $content      .= $this->_format_date_time($this->trigger['value']);
3532 3532
     else {
3533
-      if( TRUE !== $this->trigger['value']['relatedStart'] )
3533
+      if (TRUE !== $this->trigger['value']['relatedStart'])
3534 3534
         $attributes .= $this->intAttrDelimiter.'RELATED=END';
3535
-      if( $this->trigger['value']['before'] )
3535
+      if ($this->trigger['value']['before'])
3536 3536
         $content    .= '-';
3537
-      $content      .= $this->_format_duration( $this->trigger['value'] );
3537
+      $content      .= $this->_format_duration($this->trigger['value']);
3538 3538
     }
3539
-    $attributes     .= $this->_createParams( $this->trigger['params'] );
3540
-    return $this->_createElement( 'TRIGGER', $attributes, $content );
3539
+    $attributes     .= $this->_createParams($this->trigger['params']);
3540
+    return $this->_createElement('TRIGGER', $attributes, $content);
3541 3541
   }
3542 3542
 /**
3543 3543
  * set calendar component property trigger
@@ -3556,86 +3556,86 @@  discard block
 block discarded – undo
3556 3556
  * @param array $params optional
3557 3557
  * @return bool
3558 3558
  */
3559
-  function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3560
-    if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3561
-      if( $this->getConfig( 'allowEmpty' )) {
3562
-        $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3559
+  function setTrigger($year, $month = null, $day = null, $week = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $relatedStart = TRUE, $before = TRUE, $params = FALSE) {
3560
+    if (empty($year) && empty($month) && empty($day) && empty($week) && empty($hour) && empty($min) && empty($sec))
3561
+      if ($this->getConfig('allowEmpty')) {
3562
+        $this->trigger = array('value' => null, 'params' => $this->_setParams($params));
3563 3563
         return TRUE;
3564 3564
       }
3565 3565
       else
3566 3566
         return FALSE;
3567
-    if( $this->_isArrayTimestampDate( $year )) { // timestamp
3568
-      $params = $this->_setParams( $month );
3569
-      $date   = $this->_timestamp2date( $year, 7 );
3570
-      foreach( $date as $k => $v )
3567
+    if ($this->_isArrayTimestampDate($year)) { // timestamp
3568
+      $params = $this->_setParams($month);
3569
+      $date   = $this->_timestamp2date($year, 7);
3570
+      foreach ($date as $k => $v)
3571 3571
         $$k = $v;
3572 3572
     }
3573
-    elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3574
-      $params = $this->_setParams( $month );
3575
-      if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3576
-           array_key_exists( 'month', $year ) &&
3577
-           array_key_exists( 'day',   $year ))) {  // so this must be a duration
3578
-        if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3573
+    elseif (is_array($year) && (is_array($month) || empty($month))) {
3574
+      $params = $this->_setParams($month);
3575
+      if (!(array_key_exists('year', $year) && // exclude date-time
3576
+           array_key_exists('month', $year) &&
3577
+           array_key_exists('day', $year))) {  // so this must be a duration
3578
+        if (isset($params['RELATED']) && ('END' == $params['RELATED']))
3579 3579
           $relatedStart = FALSE;
3580 3580
         else
3581
-          $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
3582
-        $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3581
+          $relatedStart = (array_key_exists('relatedStart', $year) && (TRUE !== $year['relatedStart'])) ? FALSE : TRUE;
3582
+        $before         = (array_key_exists('before', $year) && (TRUE !== $year['before'])) ? FALSE : TRUE;
3583 3583
       }
3584
-      $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
3585
-      $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null;
3586
-      $day   = ( array_key_exists( 'day',   $year )) ? $year['day']   : null;
3587
-      $week  = ( array_key_exists( 'week',  $year )) ? $year['week']  : null;
3588
-      $hour  = ( array_key_exists( 'hour',  $year )) ? $year['hour']  : 0; //null;
3589
-      $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3590
-      $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3584
+      $SSYY  = (array_key_exists('year', $year)) ? $year['year'] : null;
3585
+      $month = (array_key_exists('month', $year)) ? $year['month'] : null;
3586
+      $day   = (array_key_exists('day', $year)) ? $year['day'] : null;
3587
+      $week  = (array_key_exists('week', $year)) ? $year['week'] : null;
3588
+      $hour  = (array_key_exists('hour', $year)) ? $year['hour'] : 0; //null;
3589
+      $min   = (array_key_exists('min', $year)) ? $year['min'] : 0; //null;
3590
+      $sec   = (array_key_exists('sec', $year)) ? $year['sec'] : 0; //null;
3591 3591
       $year  = $SSYY;
3592 3592
     }
3593
-    elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3594
-      $params = $this->_setParams( $month );
3595
-      if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3596
-        $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3597
-        $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3598
-        if(     'P'  != $year{0} )
3599
-          $year       = substr( $year, 1 );
3600
-        $date         = $this->_duration_string( $year);
3593
+    elseif (is_string($year) && (is_array($month) || empty($month))) {  // duration or date in a string
3594
+      $params = $this->_setParams($month);
3595
+      if (in_array($year{0}, array('P', '+', '-'))) { // duration
3596
+        $relatedStart = (isset($params['RELATED']) && ('END' == $params['RELATED'])) ? FALSE : TRUE;
3597
+        $before       = ('-' == $year{0} ) ? TRUE : FALSE;
3598
+        if ('P' != $year{0} )
3599
+          $year       = substr($year, 1);
3600
+        $date         = $this->_duration_string($year);
3601 3601
       }
3602 3602
       else   // date
3603
-        $date    = $this->_date_time_string( $year, 7 );
3604
-      unset( $year, $month, $day );
3605
-      foreach( $date as $k => $v )
3603
+        $date = $this->_date_time_string($year, 7);
3604
+      unset($year, $month, $day);
3605
+      foreach ($date as $k => $v)
3606 3606
         $$k = $v;
3607 3607
     }
3608 3608
     else // single values in function input parameters
3609
-      $params = $this->_setParams( $params );
3610
-    if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3609
+      $params = $this->_setParams($params);
3610
+    if (!empty($year) && !empty($month) && !empty($day)) { // date
3611 3611
       $params['VALUE'] = 'DATE-TIME';
3612
-      $hour = ( $hour ) ? $hour : 0;
3613
-      $min  = ( $min  ) ? $min  : 0;
3614
-      $sec  = ( $sec  ) ? $sec  : 0;
3615
-      $this->trigger = array( 'params' => $params );
3616
-      $this->trigger['value'] = array( 'year'  => $year
3612
+      $hour = ($hour) ? $hour : 0;
3613
+      $min  = ($min) ? $min : 0;
3614
+      $sec  = ($sec) ? $sec : 0;
3615
+      $this->trigger = array('params' => $params);
3616
+      $this->trigger['value'] = array('year'  => $year
3617 3617
                                      , 'month' => $month
3618 3618
                                      , 'day'   => $day
3619 3619
                                      , 'hour'  => $hour
3620 3620
                                      , 'min'   => $min
3621 3621
                                      , 'sec'   => $sec
3622
-                                     , 'tz'    => 'Z' );
3622
+                                     , 'tz'    => 'Z');
3623 3623
       return TRUE;
3624 3624
     }
3625
-    elseif(( empty( $year ) && empty( $month )) &&    // duration
3626
-           (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3627
-      unset( $params['RELATED'] ); // set at output creation (END only)
3628
-      unset( $params['VALUE'] );   // 'DURATION' default
3629
-      $this->trigger = array( 'params' => $params );
3630
-      $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE;
3631
-      $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3632
-      $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3633
-                                      , 'before'       => $before );
3634
-      if( !empty( $week )) $this->trigger['value']['week'] = $week;
3635
-      if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3636
-      if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3637
-      if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3638
-      if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
3625
+    elseif ((empty($year) && empty($month)) && // duration
3626
+           (!empty($week) || !empty($day) || !empty($hour) || !empty($min) || !empty($sec))) {
3627
+      unset($params['RELATED']); // set at output creation (END only)
3628
+      unset($params['VALUE']); // 'DURATION' default
3629
+      $this->trigger = array('params' => $params);
3630
+      $relatedStart = (FALSE !== $relatedStart) ? TRUE : FALSE;
3631
+      $before       = (FALSE !== $before) ? TRUE : FALSE;
3632
+      $this->trigger['value'] = array('relatedStart' => $relatedStart
3633
+                                      , 'before'       => $before);
3634
+      if (!empty($week)) $this->trigger['value']['week'] = $week;
3635
+      if (!empty($day)) $this->trigger['value']['day']  = $day;
3636
+      if (!empty($hour)) $this->trigger['value']['hour'] = $hour;
3637
+      if (!empty($min)) $this->trigger['value']['min']  = $min;
3638
+      if (!empty($sec)) $this->trigger['value']['sec']  = $sec;
3639 3639
       return TRUE;
3640 3640
     }
3641 3641
     return FALSE;
@@ -3652,11 +3652,11 @@  discard block
 block discarded – undo
3652 3652
  * @return string
3653 3653
  */
3654 3654
   function createTzid() {
3655
-    if( empty( $this->tzid )) return FALSE;
3656
-    if( empty( $this->tzid['value'] ))
3657
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
3658
-    $attributes = $this->_createParams( $this->tzid['params'] );
3659
-    return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3655
+    if (empty($this->tzid)) return FALSE;
3656
+    if (empty($this->tzid['value']))
3657
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZID') : FALSE;
3658
+    $attributes = $this->_createParams($this->tzid['params']);
3659
+    return $this->_createElement('TZID', $attributes, $this->_strrep($this->tzid['value']));
3660 3660
   }
3661 3661
 /**
3662 3662
  * set calendar component property tzid
@@ -3667,9 +3667,9 @@  discard block
 block discarded – undo
3667 3667
  * @param array $params optional
3668 3668
  * @return bool
3669 3669
  */
3670
-  function setTzid( $value, $params=FALSE ) {
3671
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3672
-    $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3670
+  function setTzid($value, $params = FALSE) {
3671
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3672
+    $this->tzid = array('value' => $value, 'params' => $this->_setParams($params));
3673 3673
     return TRUE;
3674 3674
   }
3675 3675
 /*********************************************************************************/
@@ -3685,14 +3685,14 @@  discard block
 block discarded – undo
3685 3685
  * @return string
3686 3686
  */
3687 3687
   function createTzname() {
3688
-    if( empty( $this->tzname )) return FALSE;
3688
+    if (empty($this->tzname)) return FALSE;
3689 3689
     $output = null;
3690
-    foreach( $this->tzname as $theName ) {
3691
-      if( !empty( $theName['value'] )) {
3692
-        $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3693
-        $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
3690
+    foreach ($this->tzname as $theName) {
3691
+      if (!empty($theName['value'])) {
3692
+        $attributes = $this->_createParams($theName['params'], array('LANGUAGE'));
3693
+        $output    .= $this->_createElement('TZNAME', $attributes, $this->_strrep($theName['value']));
3694 3694
       }
3695
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3695
+      elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('TZNAME');
3696 3696
     }
3697 3697
     return $output;
3698 3698
   }
@@ -3706,9 +3706,9 @@  discard block
 block discarded – undo
3706 3706
  * @param integer $index, optional
3707 3707
  * @return bool
3708 3708
  */
3709
-  function setTzname( $value, $params=FALSE, $index=FALSE ) {
3710
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3711
-    $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3709
+  function setTzname($value, $params = FALSE, $index = FALSE) {
3710
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3711
+    $this->_setMval($this->tzname, $value, $params, FALSE, $index);
3712 3712
     return TRUE;
3713 3713
   }
3714 3714
 /*********************************************************************************/
@@ -3723,11 +3723,11 @@  discard block
 block discarded – undo
3723 3723
  * @return string
3724 3724
  */
3725 3725
   function createTzoffsetfrom() {
3726
-    if( empty( $this->tzoffsetfrom )) return FALSE;
3727
-    if( empty( $this->tzoffsetfrom['value'] ))
3728
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
3729
-    $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3730
-    return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3726
+    if (empty($this->tzoffsetfrom)) return FALSE;
3727
+    if (empty($this->tzoffsetfrom['value']))
3728
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETFROM') : FALSE;
3729
+    $attributes = $this->_createParams($this->tzoffsetfrom['params']);
3730
+    return $this->_createElement('TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value']);
3731 3731
   }
3732 3732
 /**
3733 3733
  * set calendar component property tzoffsetfrom
@@ -3738,9 +3738,9 @@  discard block
 block discarded – undo
3738 3738
  * @param string $params optional
3739 3739
  * @return bool
3740 3740
  */
3741
-  function setTzoffsetfrom( $value, $params=FALSE ) {
3742
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3743
-    $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3741
+  function setTzoffsetfrom($value, $params = FALSE) {
3742
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3743
+    $this->tzoffsetfrom = array('value' => $value, 'params' => $this->_setParams($params));
3744 3744
     return TRUE;
3745 3745
   }
3746 3746
 /*********************************************************************************/
@@ -3755,11 +3755,11 @@  discard block
 block discarded – undo
3755 3755
  * @return string
3756 3756
  */
3757 3757
   function createTzoffsetto() {
3758
-    if( empty( $this->tzoffsetto )) return FALSE;
3759
-    if( empty( $this->tzoffsetto['value'] ))
3760
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
3761
-    $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3762
-    return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3758
+    if (empty($this->tzoffsetto)) return FALSE;
3759
+    if (empty($this->tzoffsetto['value']))
3760
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETTO') : FALSE;
3761
+    $attributes = $this->_createParams($this->tzoffsetto['params']);
3762
+    return $this->_createElement('TZOFFSETTO', $attributes, $this->tzoffsetto['value']);
3763 3763
   }
3764 3764
 /**
3765 3765
  * set calendar component property tzoffsetto
@@ -3770,9 +3770,9 @@  discard block
 block discarded – undo
3770 3770
  * @param string $params optional
3771 3771
  * @return bool
3772 3772
  */
3773
-  function setTzoffsetto( $value, $params=FALSE ) {
3774
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3775
-    $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3773
+  function setTzoffsetto($value, $params = FALSE) {
3774
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3775
+    $this->tzoffsetto = array('value' => $value, 'params' => $this->_setParams($params));
3776 3776
     return TRUE;
3777 3777
   }
3778 3778
 /*********************************************************************************/
@@ -3787,11 +3787,11 @@  discard block
 block discarded – undo
3787 3787
  * @return string
3788 3788
  */
3789 3789
   function createTzurl() {
3790
-    if( empty( $this->tzurl )) return FALSE;
3791
-    if( empty( $this->tzurl['value'] ))
3792
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
3793
-    $attributes = $this->_createParams( $this->tzurl['params'] );
3794
-    return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3790
+    if (empty($this->tzurl)) return FALSE;
3791
+    if (empty($this->tzurl['value']))
3792
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZURL') : FALSE;
3793
+    $attributes = $this->_createParams($this->tzurl['params']);
3794
+    return $this->_createElement('TZURL', $attributes, $this->tzurl['value']);
3795 3795
   }
3796 3796
 /**
3797 3797
  * set calendar component property tzurl
@@ -3802,9 +3802,9 @@  discard block
 block discarded – undo
3802 3802
  * @param string $params optional
3803 3803
  * @return boll
3804 3804
  */
3805
-  function setTzurl( $value, $params=FALSE ) {
3806
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3807
-    $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3805
+  function setTzurl($value, $params = FALSE) {
3806
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3807
+    $this->tzurl = array('value' => $value, 'params' => $this->_setParams($params));
3808 3808
     return TRUE;
3809 3809
   }
3810 3810
 /*********************************************************************************/
@@ -3819,10 +3819,10 @@  discard block
 block discarded – undo
3819 3819
  * @return string
3820 3820
  */
3821 3821
   function createUid() {
3822
-    if( 0 >= count( $this->uid ))
3822
+    if (0 >= count($this->uid))
3823 3823
       $this->_makeuid();
3824
-    $attributes = $this->_createParams( $this->uid['params'] );
3825
-    return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3824
+    $attributes = $this->_createParams($this->uid['params']);
3825
+    return $this->_createElement('UID', $attributes, $this->uid['value']);
3826 3826
   }
3827 3827
 /**
3828 3828
  * create an unique id for this calendar component object instance
@@ -3836,13 +3836,13 @@  discard block
 block discarded – undo
3836 3836
     $unique = substr(microtime(), 2, 4);
3837 3837
     $base   = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890';
3838 3838
     $start  = 0;
3839
-    $end    = strlen( $base ) - 1;
3839
+    $end    = strlen($base) - 1;
3840 3840
     $length = 6;
3841 3841
     $str    = null;
3842
-    for( $p = 0; $p < $length; $p++ )
3843
-      $unique .= $base{mt_rand( $start, $end )};
3844
-    $this->uid = array( 'params' => null );
3845
-    $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3842
+    for ($p = 0; $p < $length; $p++)
3843
+      $unique .= $base{mt_rand($start, $end)};
3844
+    $this->uid = array('params' => null);
3845
+    $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig('unique_id');
3846 3846
   }
3847 3847
 /**
3848 3848
  * set calendar component property uid
@@ -3853,9 +3853,9 @@  discard block
 block discarded – undo
3853 3853
  * @param string $params optional
3854 3854
  * @return bool
3855 3855
  */
3856
-  function setUid( $value, $params=FALSE ) {
3857
-    if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
3858
-    $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3856
+  function setUid($value, $params = FALSE) {
3857
+    if (empty($value)) return FALSE; // no allowEmpty check here !!!!
3858
+    $this->uid = array('value' => $value, 'params' => $this->_setParams($params));
3859 3859
     return TRUE;
3860 3860
   }
3861 3861
 /*********************************************************************************/
@@ -3870,11 +3870,11 @@  discard block
 block discarded – undo
3870 3870
  * @return string
3871 3871
  */
3872 3872
   function createUrl() {
3873
-    if( empty( $this->url )) return FALSE;
3874
-    if( empty( $this->url['value'] ))
3875
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
3876
-    $attributes = $this->_createParams( $this->url['params'] );
3877
-    return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3873
+    if (empty($this->url)) return FALSE;
3874
+    if (empty($this->url['value']))
3875
+      return ($this->getConfig('allowEmpty')) ? $this->_createElement('URL') : FALSE;
3876
+    $attributes = $this->_createParams($this->url['params']);
3877
+    return $this->_createElement('URL', $attributes, $this->url['value']);
3878 3878
   }
3879 3879
 /**
3880 3880
  * set calendar component property url
@@ -3885,9 +3885,9 @@  discard block
 block discarded – undo
3885 3885
  * @param string $params optional
3886 3886
  * @return bool
3887 3887
  */
3888
-  function setUrl( $value, $params=FALSE ) {
3889
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3890
-    $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3888
+  function setUrl($value, $params = FALSE) {
3889
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3890
+    $this->url = array('value' => $value, 'params' => $this->_setParams($params));
3891 3891
     return TRUE;
3892 3892
   }
3893 3893
 /*********************************************************************************/
@@ -3902,22 +3902,22 @@  discard block
 block discarded – undo
3902 3902
  * @return string
3903 3903
  */
3904 3904
   function createXprop() {
3905
-    if( empty( $this->xprop )) return FALSE;
3905
+    if (empty($this->xprop)) return FALSE;
3906 3906
     $output = null;
3907
-    foreach( $this->xprop as $label => $xpropPart ) {
3908
-      if( empty( $xpropPart['value'] )) {
3909
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
3907
+    foreach ($this->xprop as $label => $xpropPart) {
3908
+      if (empty($xpropPart['value'])) {
3909
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($label);
3910 3910
         continue;
3911 3911
       }
3912
-      $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3913
-      if( is_array( $xpropPart['value'] )) {
3914
-        foreach( $xpropPart['value'] as $pix => $theXpart )
3915
-          $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
3916
-        $xpropPart['value']  = implode( ',', $xpropPart['value'] );
3912
+      $attributes = $this->_createParams($xpropPart['params'], array('LANGUAGE'));
3913
+      if (is_array($xpropPart['value'])) {
3914
+        foreach ($xpropPart['value'] as $pix => $theXpart)
3915
+          $xpropPart['value'][$pix] = $this->_strrep($theXpart);
3916
+        $xpropPart['value'] = implode(',', $xpropPart['value']);
3917 3917
       }
3918 3918
       else
3919
-        $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3920
-      $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3919
+        $xpropPart['value'] = $this->_strrep($xpropPart['value']);
3920
+      $output .= $this->_createElement($label, $attributes, $xpropPart['value']);
3921 3921
     }
3922 3922
     return $output;
3923 3923
   }
@@ -3931,14 +3931,14 @@  discard block
 block discarded – undo
3931 3931
  * @param array $params optional
3932 3932
  * @return bool
3933 3933
  */
3934
-  function setXprop( $label, $value, $params=FALSE ) {
3935
-    if( empty( $label )) return;
3936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3937
-    $xprop           = array( 'value' => $value );
3934
+  function setXprop($label, $value, $params = FALSE) {
3935
+    if (empty($label)) return;
3936
+    if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE;
3937
+    $xprop           = array('value' => $value);
3938 3938
     $toolbox         = new calendarComponent();
3939
-    $xprop['params'] = $toolbox->_setParams( $params );
3940
-    if( !is_array( $this->xprop )) $this->xprop = array();
3941
-    $this->xprop[strtoupper( $label )] = $xprop;
3939
+    $xprop['params'] = $toolbox->_setParams($params);
3940
+    if (!is_array($this->xprop)) $this->xprop = array();
3941
+    $this->xprop[strtoupper($label)] = $xprop;
3942 3942
     return TRUE;
3943 3943
   }
3944 3944
 /*********************************************************************************/
@@ -3952,10 +3952,10 @@  discard block
 block discarded – undo
3952 3952
  */
3953 3953
   function _createFormat() {
3954 3954
     $objectname                   = null;
3955
-    switch( $this->format ) {
3955
+    switch ($this->format) {
3956 3956
       case 'xcal':
3957
-        $objectname               = ( isset( $this->timezonetype )) ?
3958
-                                 strtolower( $this->timezonetype )  :  strtolower( $this->objName );
3957
+        $objectname               = (isset($this->timezonetype)) ?
3958
+                                 strtolower($this->timezonetype) : strtolower($this->objName);
3959 3959
         $this->componentStart1    = $this->elementStart1 = '<';
3960 3960
         $this->componentStart2    = $this->elementStart2 = '>';
3961 3961
         $this->componentEnd1      = $this->elementEnd1   = '</';
@@ -3965,8 +3965,8 @@  discard block
 block discarded – undo
3965 3965
         $this->valueInit          = null;
3966 3966
         break;
3967 3967
       default:
3968
-        $objectname               = ( isset( $this->timezonetype )) ?
3969
-                                 strtoupper( $this->timezonetype )  :  strtoupper( $this->objName );
3968
+        $objectname               = (isset($this->timezonetype)) ?
3969
+                                 strtoupper($this->timezonetype) : strtoupper($this->objName);
3970 3970
         $this->componentStart1    = 'BEGIN:';
3971 3971
         $this->componentStart2    = null;
3972 3972
         $this->componentEnd1      = 'END:';
@@ -3992,82 +3992,82 @@  discard block
 block discarded – undo
3992 3992
  * @param string $content property content (optional)
3993 3993
  * @return string
3994 3994
  */
3995
-  function _createElement( $label, $attributes=null, $content=FALSE ) {
3996
-    $label  = $this->_formatPropertyName( $label );
3995
+  function _createElement($label, $attributes = null, $content = FALSE) {
3996
+    $label  = $this->_formatPropertyName($label);
3997 3997
     $output = $this->elementStart1.$label;
3998 3998
     $categoriesAttrLang = null;
3999 3999
     $attachInlineBinary = FALSE;
4000 4000
     $attachfmttype      = null;
4001
-    if( !empty( $attributes ))  {
4002
-      $attributes  = trim( $attributes );
4003
-      if ( 'xcal' == $this->format) {
4004
-        $attributes2 = explode( $this->intAttrDelimiter, $attributes );
4001
+    if (!empty($attributes)) {
4002
+      $attributes = trim($attributes);
4003
+      if ('xcal' == $this->format) {
4004
+        $attributes2 = explode($this->intAttrDelimiter, $attributes);
4005 4005
         $attributes  = null;
4006
-        foreach( $attributes2 as $attribute ) {
4007
-          $attrKVarr = explode( '=', $attribute );
4008
-          if( empty( $attrKVarr[0] ))
4006
+        foreach ($attributes2 as $attribute) {
4007
+          $attrKVarr = explode('=', $attribute);
4008
+          if (empty($attrKVarr[0]))
4009 4009
             continue;
4010
-          if( !isset( $attrKVarr[1] )) {
4010
+          if (!isset($attrKVarr[1])) {
4011 4011
             $attrValue = $attrKVarr[0];
4012 4012
             $attrKey   = null;
4013 4013
           }
4014
-          elseif( 2 == count( $attrKVarr)) {
4015
-            $attrKey   = strtolower( $attrKVarr[0] );
4014
+          elseif (2 == count($attrKVarr)) {
4015
+            $attrKey   = strtolower($attrKVarr[0]);
4016 4016
             $attrValue = $attrKVarr[1];
4017 4017
           }
4018 4018
           else {
4019
-            $attrKey   = strtolower( $attrKVarr[0] );
4020
-            unset( $attrKVarr[0] );
4021
-            $attrValue = implode( '=', $attrKVarr );
4019
+            $attrKey   = strtolower($attrKVarr[0]);
4020
+            unset($attrKVarr[0]);
4021
+            $attrValue = implode('=', $attrKVarr);
4022 4022
           }
4023
-          if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4023
+          if (('attach' == $label) && (in_array($attrKey, array('fmttype', 'encoding', 'value')))) {
4024 4024
             $attachInlineBinary = TRUE;
4025
-            if( 'fmttype' == $attrKey )
4025
+            if ('fmttype' == $attrKey)
4026 4026
               $attachfmttype = $attrKey.'='.$attrValue;
4027 4027
             continue;
4028 4028
           }
4029
-          elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4029
+          elseif (('categories' == $label) && ('language' == $attrKey))
4030 4030
             $categoriesAttrLang = $attrKey.'='.$attrValue;
4031 4031
           else {
4032
-            $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4033
-            $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4034
-            if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
4035
-              $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 ));
4036
-              $attrValue = str_replace( '"', '', $attrValue );
4032
+            $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' ';
4033
+            $attributes .= (!empty($attrKey)) ? $attrKey.'=' : null;
4034
+            if (('"' == substr($attrValue, 0, 1)) && ('"' == substr($attrValue, -1))) {
4035
+              $attrValue = substr($attrValue, 1, (strlen($attrValue) - 2));
4036
+              $attrValue = str_replace('"', '', $attrValue);
4037 4037
             }
4038
-            $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4038
+            $attributes .= '"'.htmlspecialchars($attrValue).'"';
4039 4039
           }
4040 4040
         }
4041 4041
       }
4042 4042
       else {
4043
-        $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4043
+        $attributes = str_replace($this->intAttrDelimiter, $this->attributeDelimiter, $attributes);
4044 4044
       }
4045 4045
     }
4046
-    if(((( 'attach' == $label ) && !$attachInlineBinary ) ||
4047
-         ( in_array( $label, array( 'tzurl', 'url' ))))      && ( 'xcal' == $this->format)) {
4046
+    if (((('attach' == $label) && !$attachInlineBinary) ||
4047
+         (in_array($label, array('tzurl', 'url')))) && ('xcal' == $this->format)) {
4048 4048
       $pos = strrpos($content, "/");
4049
-      $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content;
4050
-      $this->xcaldecl[] = array( 'xmldecl'  => 'ENTITY'
4049
+      $docname = ($pos !== false) ? substr($content, (1 - strlen($content) + $pos)) : $content;
4050
+      $this->xcaldecl[] = array('xmldecl'  => 'ENTITY'
4051 4051
                                , 'uri'      => $docname
4052 4052
                                , 'ref'      => 'SYSTEM'
4053 4053
                                , 'external' => $content
4054 4054
                                , 'type'     => 'NDATA'
4055
-                               , 'type2'    => 'BINERY' );
4056
-      $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4055
+                               , 'type2'    => 'BINERY');
4056
+      $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' ';
4057 4057
       $attributes .= 'uri="'.$docname.'"';
4058 4058
       $content = null;
4059
-      if( 'attach' == $label ) {
4060
-        $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes );
4061
-        $content = $this->_createElement( 'extref', $attributes, null );
4059
+      if ('attach' == $label) {
4060
+        $attributes = str_replace($this->attributeDelimiter, $this->intAttrDelimiter, $attributes);
4061
+        $content = $this->_createElement('extref', $attributes, null);
4062 4062
         $attributes = null;
4063 4063
       }
4064 4064
     }
4065
-    elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4066
-      $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4065
+    elseif (('attach' == $label) && $attachInlineBinary && ('xcal' == $this->format)) {
4066
+      $content = $this->nl.$this->_createElement('b64bin', $attachfmttype, $content); // max one attribute
4067 4067
     }
4068 4068
     $output .= $attributes;
4069
-    if( !$content ) {
4070
-      switch( $this->format ) {
4069
+    if (!$content) {
4070
+      switch ($this->format) {
4071 4071
         case 'xcal':
4072 4072
           $output .= ' /';
4073 4073
           $output .= $this->elementStart2;
@@ -4075,18 +4075,18 @@  discard block
 block discarded – undo
4075 4075
           break;
4076 4076
         default:
4077 4077
           $output .= $this->elementStart2.$this->valueInit;
4078
-          return $this->_size75( $output );
4078
+          return $this->_size75($output);
4079 4079
           break;
4080 4080
       }
4081 4081
     }
4082 4082
     $output .= $this->elementStart2;
4083 4083
     $output .= $this->valueInit.$content;
4084
-    switch( $this->format ) {
4084
+    switch ($this->format) {
4085 4085
       case 'xcal':
4086 4086
         return $output.$this->elementEnd1.$label.$this->elementEnd2;
4087 4087
         break;
4088 4088
       default:
4089
-        return $this->_size75( $output );
4089
+        return $this->_size75($output);
4090 4090
         break;
4091 4091
     }
4092 4092
   }
@@ -4099,36 +4099,36 @@  discard block
 block discarded – undo
4099 4099
  * @param array $ctrKeys optional
4100 4100
  * @return string
4101 4101
  */
4102
-  function _createParams( $params=array(), $ctrKeys=array() ) {
4102
+  function _createParams($params = array(), $ctrKeys = array()) {
4103 4103
     $attrLANG = $attr1 = $attr2 = null;
4104
-    $CNattrKey   = ( in_array( 'CN',       $ctrKeys )) ? TRUE : FALSE ;
4105
-    $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ;
4104
+    $CNattrKey   = (in_array('CN', $ctrKeys)) ? TRUE : FALSE;
4105
+    $LANGattrKey = (in_array('LANGUAGE', $ctrKeys)) ? TRUE : FALSE;
4106 4106
     $CNattrExist = $LANGattrExist = FALSE;
4107
-    if( is_array( $params )) {
4108
-      foreach( $params as $paramKey => $paramValue ) {
4109
-        if( is_int( $paramKey ))
4107
+    if (is_array($params)) {
4108
+      foreach ($params as $paramKey => $paramValue) {
4109
+        if (is_int($paramKey))
4110 4110
           $attr2            .= $this->intAttrDelimiter.$paramValue;
4111
-        elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4111
+        elseif (('LANGUAGE' == $paramKey) && $LANGattrKey) {
4112 4112
           $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4113 4113
           $LANGattrExist     = TRUE;
4114 4114
         }
4115
-        elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4115
+        elseif (('CN' == $paramKey) && $CNattrKey) {
4116 4116
           $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4117 4117
           $CNattrExist       = TRUE;
4118 4118
         }
4119
-        elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4119
+        elseif (('ALTREP' == $paramKey) && in_array($paramKey, $ctrKeys))
4120 4120
           $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4121
-        elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4121
+        elseif (('DIR' == $paramKey) && in_array($paramKey, $ctrKeys))
4122 4122
           $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4123
-        elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4123
+        elseif (('SENT-BY' == $paramKey) && in_array($paramKey, $ctrKeys))
4124 4124
           $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4125 4125
         else
4126 4126
           $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4127 4127
       }
4128 4128
     }
4129
-    if( !$LANGattrExist ) {
4130
-      $lang = $this->getConfig( 'language' );
4131
-      if(( $CNattrExist || $LANGattrKey ) && $lang )
4129
+    if (!$LANGattrExist) {
4130
+      $lang = $this->getConfig('language');
4131
+      if (($CNattrExist || $LANGattrKey) && $lang)
4132 4132
         $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4133 4133
     }
4134 4134
     return $attrLANG.$attr1.$attr2;
@@ -4142,47 +4142,47 @@  discard block
 block discarded – undo
4142 4142
  * @param int $parno, no of date parts (i.e. year, month.. .)
4143 4143
  * @return array $params, property parameters
4144 4144
  */
4145
-  function _chkdatecfg( $theDate, & $parno, & $params ) {
4146
-    if( isset( $params['TZID'] ))
4145
+  function _chkdatecfg($theDate, & $parno, & $params) {
4146
+    if (isset($params['TZID']))
4147 4147
       $parno = 6;
4148
-    elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4148
+    elseif (isset($params['VALUE']) && ('DATE' == $params['VALUE']))
4149 4149
       $parno = 3;
4150 4150
     else {
4151
-      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4151
+      if (isset($params['VALUE']) && ('PERIOD' == $params['VALUE']))
4152 4152
         $parno = 7;
4153
-      if( is_array( $theDate )) {
4154
-        if( isset( $theDate['timestamp'] ))
4155
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4153
+      if (is_array($theDate)) {
4154
+        if (isset($theDate['timestamp']))
4155
+          $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : null;
4156 4156
         else
4157
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4158
-        if( !empty( $tzid )) {
4157
+          $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : (7 == count($theDate)) ? end($theDate) : null;
4158
+        if (!empty($tzid)) {
4159 4159
           $parno = 7;
4160
-          if( !$this->_isOffset( $tzid ))
4160
+          if (!$this->_isOffset($tzid))
4161 4161
             $params['TZID'] = $tzid; // save only timezone
4162 4162
         }
4163
-        elseif( !$parno && ( 3 == count( $theDate )) && 
4164
-          ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4163
+        elseif (!$parno && (3 == count($theDate)) && 
4164
+          (isset($params['VALUE']) && ('DATE' == $params['VALUE'])))
4165 4165
           $parno = 3;
4166 4166
         else
4167 4167
           $parno = 6;
4168 4168
       }
4169 4169
       else { // string
4170
-        $date = trim( $theDate );
4171
-        if( 'Z' == substr( $date, -1 ))
4170
+        $date = trim($theDate);
4171
+        if ('Z' == substr($date, -1))
4172 4172
           $parno = 7; // UTC DATE-TIME
4173
-        elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && 
4174
-          ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4173
+        elseif (((8 == strlen($date) && ctype_digit($date)) || (11 >= strlen($date))) && 
4174
+          (!isset($params['VALUE']) || !in_array($params['VALUE'], array('DATE-TIME', 'PERIOD'))))
4175 4175
           $parno = 3; // DATE
4176
-        $date = $this->_date_time_string( $date, $parno );
4177
-        if( !empty( $date['tz'] )) {
4176
+        $date = $this->_date_time_string($date, $parno);
4177
+        if (!empty($date['tz'])) {
4178 4178
           $parno = 7;
4179
-          if( !$this->_isOffset( $date['tz'] ))
4179
+          if (!$this->_isOffset($date['tz']))
4180 4180
             $params['TZID'] = $date['tz']; // save only timezone
4181 4181
         }
4182
-        elseif( empty( $parno ))
4182
+        elseif (empty($parno))
4183 4183
           $parno = 6;
4184 4184
       }
4185
-      if( isset( $params['TZID'] ))
4185
+      if (isset($params['TZID']))
4186 4186
         $parno = 6;
4187 4187
     }
4188 4188
   }
@@ -4197,28 +4197,28 @@  discard block
 block discarded – undo
4197 4197
  * @param array $duration, optional
4198 4198
  * @return array duration
4199 4199
  */
4200
-  function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4201
-    if( !$startdate || !$enddate ) {
4202
-      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4200
+  function _date2duration($startdate = FALSE, $enddate = FALSE) {
4201
+    if (!$startdate || !$enddate) {
4202
+      if (FALSE === ($startdate = $this->getProperty('dtstart')))
4203 4203
         return null;
4204
-      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4205
-        if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4204
+      if (FALSE === ($enddate   = $this->getProperty('dtend')))    // vevent/vfreebusy
4205
+        if (FALSE === ($enddate   = $this->getProperty('due')))      // vtodo
4206 4206
           return null;
4207 4207
     }
4208
-    if( !$startdate || !$enddate )
4208
+    if (!$startdate || !$enddate)
4209 4209
       return null;
4210
-    $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4211
-    $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4210
+    $startWdate  = mktime(0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year']);
4211
+    $endWdate    = mktime(0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year']);
4212 4212
     $wduration   = $endWdate - $startWdate;
4213 4213
     $dur         = array();
4214
-    $dur['week'] = (int) floor( $wduration / ( 7 * 24 * 60 * 60 ));
4215
-    $wduration   =              $wduration % ( 7 * 24 * 60 * 60 );
4216
-    $dur['day']  = (int) floor( $wduration / ( 24 * 60 * 60 ));
4217
-    $wduration   =              $wduration % ( 24 * 60 * 60 );
4218
-    $dur['hour'] = (int) floor( $wduration / ( 60 * 60 ));
4219
-    $wduration   =              $wduration % ( 60 * 60 );
4220
-    $dur['min']  = (int) floor( $wduration / ( 60 ));
4221
-    $dur['sec']  = (int)        $wduration % ( 60 );
4214
+    $dur['week'] = (int) floor($wduration / (7 * 24 * 60 * 60));
4215
+    $wduration   = $wduration % (7 * 24 * 60 * 60);
4216
+    $dur['day']  = (int) floor($wduration / (24 * 60 * 60));
4217
+    $wduration   = $wduration % (24 * 60 * 60);
4218
+    $dur['hour'] = (int) floor($wduration / (60 * 60));
4219
+    $wduration   = $wduration % (60 * 60);
4220
+    $dur['min']  = (int) floor($wduration / (60));
4221
+    $dur['sec']  = (int) $wduration % (60);
4222 4222
     return $dur;
4223 4223
   }
4224 4224
 /**
@@ -4230,19 +4230,19 @@  discard block
 block discarded – undo
4230 4230
  * @param string $tz        timezone
4231 4231
  * @return timestamp
4232 4232
  */
4233
-  function _date2timestamp( $datetime, $tz=null ) {
4233
+  function _date2timestamp($datetime, $tz = null) {
4234 4234
     $output = null;
4235
-    if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4236
-    if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4237
-    if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4238
-    foreach( $datetime as $dkey => $dvalue ) {
4239
-      if( 'tz' != $dkey )
4235
+    if (!isset($datetime['hour'])) $datetime['hour'] = '0';
4236
+    if (!isset($datetime['min']))  $datetime['min']  = '0';
4237
+    if (!isset($datetime['sec']))  $datetime['sec']  = '0';
4238
+    foreach ($datetime as $dkey => $dvalue) {
4239
+      if ('tz' != $dkey)
4240 4240
         $datetime[$dkey] = (integer) $dvalue;
4241 4241
     }
4242
-    if( $tz )
4242
+    if ($tz)
4243 4243
       $datetime['tz'] = $tz;
4244
-    $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4245
-    $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4244
+    $offset = (isset($datetime['tz']) && ('' < trim($datetime['tz']))) ? $this->_tz2offset($datetime['tz']) : 0;
4245
+    $output = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4246 4246
     return $output;
4247 4247
   }
4248 4248
 /**
@@ -4254,16 +4254,16 @@  discard block
 block discarded – undo
4254 4254
  * @param int $parno optional, default FALSE
4255 4255
  * @return array
4256 4256
  */
4257
-  function _date_time_array( $datetime, $parno=FALSE ) {
4257
+  function _date_time_array($datetime, $parno = FALSE) {
4258 4258
     $output = array();
4259
-    foreach( $datetime as $dateKey => $datePart ) {
4260
-      switch ( $dateKey ) {
4259
+    foreach ($datetime as $dateKey => $datePart) {
4260
+      switch ($dateKey) {
4261 4261
         case '0': case 'year':   $output['year']  = $datePart; break;
4262 4262
         case '1': case 'month':  $output['month'] = $datePart; break;
4263 4263
         case '2': case 'day':    $output['day']   = $datePart; break;
4264 4264
       }
4265
-      if( 3 != $parno ) {
4266
-        switch ( $dateKey ) {
4265
+      if (3 != $parno) {
4266
+        switch ($dateKey) {
4267 4267
           case '0':
4268 4268
           case '1':
4269 4269
           case '2': break;
@@ -4274,12 +4274,12 @@  discard block
 block discarded – undo
4274 4274
         }
4275 4275
       }
4276 4276
     }
4277
-    if( 3 != $parno ) {
4278
-      if( !isset( $output['hour'] ))
4277
+    if (3 != $parno) {
4278
+      if (!isset($output['hour']))
4279 4279
         $output['hour'] = 0;
4280
-      if( !isset( $output['min']  ))
4280
+      if (!isset($output['min']))
4281 4281
         $output['min'] = 0;
4282
-      if( !isset( $output['sec']  ))
4282
+      if (!isset($output['sec']))
4283 4283
         $output['sec'] = 0;
4284 4284
     }
4285 4285
     return $output;
@@ -4293,88 +4293,88 @@  discard block
 block discarded – undo
4293 4293
  * @param int $parno optional, default FALSE
4294 4294
  * @return array
4295 4295
  */
4296
-  function _date_time_string( $datetime, $parno=FALSE ) {
4297
-    $datetime = (string) trim( $datetime );
4296
+  function _date_time_string($datetime, $parno = FALSE) {
4297
+    $datetime = (string) trim($datetime);
4298 4298
     $tz  = null;
4299
-    $len = strlen( $datetime ) - 1;
4300
-    if( 'Z' == substr( $datetime, -1 )) {
4299
+    $len = strlen($datetime) - 1;
4300
+    if ('Z' == substr($datetime, -1)) {
4301 4301
       $tz = 'Z';
4302
-      $datetime = trim( substr( $datetime, 0, $len ));
4302
+      $datetime = trim(substr($datetime, 0, $len));
4303 4303
     }
4304
-    elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4305
-                  ( '-' == substr( $datetime, -3, 1 )) ||
4306
-                  ( ':' == substr( $datetime, -3, 1 )) ||
4307
-                  ( '.' == substr( $datetime, -3, 1 ))) {
4304
+    elseif ((ctype_digit(substr($datetime, -2, 2))) && // time or date
4305
+                  ('-' == substr($datetime, -3, 1)) ||
4306
+                  (':' == substr($datetime, -3, 1)) ||
4307
+                  ('.' == substr($datetime, -3, 1))) {
4308 4308
       $continue = TRUE;
4309 4309
     }
4310
-    elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4311
-            ( ' +' == substr( $datetime, -6, 2 )) ||
4312
-            ( ' -' == substr( $datetime, -6, 2 ))) {
4313
-      $tz = substr( $datetime, -5, 5 );
4314
-      $datetime = substr( $datetime, 0, ($len - 5));
4310
+    elseif ((ctype_digit(substr($datetime, -4, 4))) && // 4 pos offset
4311
+            (' +' == substr($datetime, -6, 2)) ||
4312
+            (' -' == substr($datetime, -6, 2))) {
4313
+      $tz = substr($datetime, -5, 5);
4314
+      $datetime = substr($datetime, 0, ($len - 5));
4315 4315
     }
4316
-    elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4317
-            ( ' +' == substr( $datetime, -8, 2 )) ||
4318
-            ( ' -' == substr( $datetime, -8, 2 ))) {
4319
-      $tz = substr( $datetime, -7, 7 );
4320
-      $datetime = substr( $datetime, 0, ($len - 7));
4316
+    elseif ((ctype_digit(substr($datetime, -6, 6))) && // 6 pos offset
4317
+            (' +' == substr($datetime, -8, 2)) ||
4318
+            (' -' == substr($datetime, -8, 2))) {
4319
+      $tz = substr($datetime, -7, 7);
4320
+      $datetime = substr($datetime, 0, ($len - 7));
4321 4321
     }
4322
-    elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4322
+    elseif ((6 < $len) && (ctype_digit(substr($datetime, -6, 6)))) {
4323 4323
       $continue = TRUE;
4324 4324
     }
4325
-    elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4325
+    elseif ('T' == substr($datetime, -7, 1)) {
4326 4326
       $continue = TRUE;
4327 4327
     }
4328 4328
     else {
4329
-      $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4330
-      for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4331
-        if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4329
+      $cx = $tx = 0; //  19970415T133000 US-Eastern
4330
+      for ($cx = -1; $cx > (9 - $len); $cx--) {
4331
+        if ((' ' == substr($datetime, $cx, 1)) || ctype_digit(substr($datetime, $cx, 1)))
4332 4332
           break; // if exists, tz ends here.. . ?
4333
-        elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4334
-             ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4333
+        elseif (ctype_alpha(substr($datetime, $cx, 1)) ||
4334
+             (in_array(substr($datetime, $cx, 1), array('-', '/'))))
4335 4335
           $tx--; // tz length counter
4336 4336
       }
4337
-      if( 0 > $tx ) {
4338
-        $tz = substr( $datetime, $tx );
4339
-        $datetime = trim( substr( $datetime, 0, $len + $tx + 1 ));
4337
+      if (0 > $tx) {
4338
+        $tz = substr($datetime, $tx);
4339
+        $datetime = trim(substr($datetime, 0, $len + $tx + 1));
4340 4340
       }
4341 4341
     }
4342
-    if( 0 < substr_count( $datetime, '-' )) {
4343
-      $datetime = str_replace( '-', '/', $datetime );
4344
-    }
4345
-    elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4346
-           ( 'T' ==      substr( $datetime, 8, 1 )) &&
4347
-            ctype_digit( substr( $datetime, 9, 6 ))) {
4348
-      $datetime = substr( $datetime,  4, 2 )
4349
-             .'/'.substr( $datetime,  6, 2 )
4350
-             .'/'.substr( $datetime,  0, 4 )
4351
-             .' '.substr( $datetime,  9, 2 )
4352
-             .':'.substr( $datetime, 11, 2 )
4353
-             .':'.substr( $datetime, 13);
4354
-    }
4355
-    $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime ));
4356
-    $tz                = trim( $tz );
4342
+    if (0 < substr_count($datetime, '-')) {
4343
+      $datetime = str_replace('-', '/', $datetime);
4344
+    }
4345
+    elseif (ctype_digit(substr($datetime, 0, 8)) &&
4346
+           ('T' == substr($datetime, 8, 1)) &&
4347
+            ctype_digit(substr($datetime, 9, 6))) {
4348
+      $datetime = substr($datetime, 4, 2)
4349
+             .'/'.substr($datetime, 6, 2)
4350
+             .'/'.substr($datetime, 0, 4)
4351
+             .' '.substr($datetime, 9, 2)
4352
+             .':'.substr($datetime, 11, 2)
4353
+             .':'.substr($datetime, 13);
4354
+    }
4355
+    $datestring = date('Y-m-d H:i:s', strtotime($datetime));
4356
+    $tz                = trim($tz);
4357 4357
     $output            = array();
4358
-    $output['year']    = substr( $datestring, 0, 4 );
4359
-    $output['month']   = substr( $datestring, 5, 2 );
4360
-    $output['day']     = substr( $datestring, 8, 2 );
4361
-    if(( 6 == $parno ) || ( 7 == $parno )) {
4362
-      $output['hour']  = substr( $datestring, 11, 2 );
4363
-      $output['min']   = substr( $datestring, 14, 2 );
4364
-      $output['sec']   = substr( $datestring, 17, 2 );
4365
-      if( !empty( $tz ))
4358
+    $output['year']    = substr($datestring, 0, 4);
4359
+    $output['month']   = substr($datestring, 5, 2);
4360
+    $output['day']     = substr($datestring, 8, 2);
4361
+    if ((6 == $parno) || (7 == $parno)) {
4362
+      $output['hour']  = substr($datestring, 11, 2);
4363
+      $output['min']   = substr($datestring, 14, 2);
4364
+      $output['sec']   = substr($datestring, 17, 2);
4365
+      if (!empty($tz))
4366 4366
         $output['tz']  = $tz;
4367 4367
     }
4368
-    elseif( 3 != $parno ) {
4369
-      if(( '00' < substr( $datestring, 11, 2 )) ||
4370
-         ( '00' < substr( $datestring, 14, 2 )) ||
4371
-         ( '00' < substr( $datestring, 17, 2 ))) {
4372
-        $output['hour']  = substr( $datestring, 11, 2 );
4373
-        $output['min']   = substr( $datestring, 14, 2 );
4374
-        $output['sec']   = substr( $datestring, 17, 2 );
4368
+    elseif (3 != $parno) {
4369
+      if (('00' < substr($datestring, 11, 2)) ||
4370
+         ('00' < substr($datestring, 14, 2)) ||
4371
+         ('00' < substr($datestring, 17, 2))) {
4372
+        $output['hour']  = substr($datestring, 11, 2);
4373
+        $output['min']   = substr($datestring, 14, 2);
4374
+        $output['sec']   = substr($datestring, 17, 2);
4375 4375
       }
4376
-      if( !empty( $tz ))
4377
-        $output['tz']  = $tz;
4376
+      if (!empty($tz))
4377
+        $output['tz'] = $tz;
4378 4378
     }
4379 4379
     return $output;
4380 4380
   }
@@ -4386,26 +4386,26 @@  discard block
 block discarded – undo
4386 4386
  * @param array $duration
4387 4387
  * @return array
4388 4388
  */
4389
-  function _duration_array( $duration ) {
4389
+  function _duration_array($duration) {
4390 4390
     $output = array();
4391
-    if(    is_array( $duration )        &&
4392
-       ( 1 == count( $duration ))       &&
4393
-              isset( $duration['sec'] ) &&
4394
-              ( 60 < $duration['sec'] )) {
4391
+    if (is_array($duration) &&
4392
+       (1 == count($duration)) &&
4393
+              isset($duration['sec']) &&
4394
+              (60 < $duration['sec'])) {
4395 4395
       $durseconds  = $duration['sec'];
4396
-      $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 ));
4397
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 * 7 );
4398
-      $output['day']  = floor( $durseconds / ( 60 * 60 * 24 ));
4399
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 );
4400
-      $output['hour'] = floor( $durseconds / ( 60 * 60 ));
4401
-      $durseconds  =           $durseconds % ( 60 * 60 );
4402
-      $output['min']  = floor( $durseconds / ( 60 ));
4403
-      $output['sec']  =      ( $durseconds % ( 60 ));
4396
+      $output['week'] = floor($durseconds / (60 * 60 * 24 * 7));
4397
+      $durseconds  = $durseconds % (60 * 60 * 24 * 7);
4398
+      $output['day']  = floor($durseconds / (60 * 60 * 24));
4399
+      $durseconds  = $durseconds % (60 * 60 * 24);
4400
+      $output['hour'] = floor($durseconds / (60 * 60));
4401
+      $durseconds  = $durseconds % (60 * 60);
4402
+      $output['min']  = floor($durseconds / (60));
4403
+      $output['sec']  = ($durseconds % (60));
4404 4404
     }
4405 4405
     else {
4406
-      foreach( $duration as $durKey => $durValue ) {
4407
-        if( empty( $durValue )) continue;
4408
-        switch ( $durKey ) {
4406
+      foreach ($duration as $durKey => $durValue) {
4407
+        if (empty($durValue)) continue;
4408
+        switch ($durKey) {
4409 4409
           case '0': case 'week': $output['week']  = $durValue; break;
4410 4410
           case '1': case 'day':  $output['day']   = $durValue; break;
4411 4411
           case '2': case 'hour': $output['hour']  = $durValue; break;
@@ -4414,19 +4414,19 @@  discard block
 block discarded – undo
4414 4414
         }
4415 4415
       }
4416 4416
     }
4417
-    if( isset( $output['week'] ) && ( 0 < $output['week'] )) {
4418
-      unset( $output['day'], $output['hour'], $output['min'], $output['sec'] );
4417
+    if (isset($output['week']) && (0 < $output['week'])) {
4418
+      unset($output['day'], $output['hour'], $output['min'], $output['sec']);
4419 4419
       return $output;
4420 4420
     }
4421
-    unset( $output['week'] );
4422
-    if( empty( $output['day'] ))
4423
-      unset( $output['day'] );
4424
-    if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4425
-      if( !isset( $output['hour'] )) $output['hour'] = 0;
4426
-      if( !isset( $output['min']  )) $output['min']  = 0;
4427
-      if( !isset( $output['sec']  )) $output['sec']  = 0;
4428
-      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4429
-        unset( $output['hour'], $output['min'], $output['sec'] );
4421
+    unset($output['week']);
4422
+    if (empty($output['day']))
4423
+      unset($output['day']);
4424
+    if (isset($output['hour']) || isset($output['min']) || isset($output['sec'])) {
4425
+      if (!isset($output['hour'])) $output['hour'] = 0;
4426
+      if (!isset($output['min'])) $output['min']  = 0;
4427
+      if (!isset($output['sec'])) $output['sec']  = 0;
4428
+      if ((0 == $output['hour']) && (0 == $output['min']) && (0 == $output['sec']))
4429
+        unset($output['hour'], $output['min'], $output['sec']);
4430 4430
     }
4431 4431
     return $output;
4432 4432
   }
@@ -4439,43 +4439,43 @@  discard block
 block discarded – undo
4439 4439
  * @param array $duration, optional
4440 4440
  * @return array, date format
4441 4441
  */
4442
-  function duration2date( $startdate=FALSE, $duration=FALSE ) {
4443
-    if( $startdate && $duration ) {
4442
+  function duration2date($startdate = FALSE, $duration = FALSE) {
4443
+    if ($startdate && $duration) {
4444 4444
       $d1               = $startdate;
4445 4445
       $dur              = $duration;
4446 4446
     }
4447
-    elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4447
+    elseif (isset($this->dtstart['value']) && isset($this->duration['value'])) {
4448 4448
       $d1               = $this->dtstart['value'];
4449 4449
       $dur              = $this->duration['value'];
4450 4450
     }
4451 4451
     else
4452 4452
       return null;
4453
-    $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4454
-    $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4455
-    $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4456
-    $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4457
-    $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4458
-    if( isset( $dur['week'] ))
4459
-      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4460
-    if( isset( $dur['day'] ))
4461
-      $dtend += ( $dur['day'] * 24 * 60 * 60 );
4462
-    if( isset( $dur['hour'] ))
4463
-      $dtend += ( $dur['hour'] * 60 *60 );
4464
-    if( isset( $dur['min'] ))
4465
-      $dtend += ( $dur['min'] * 60 );
4466
-    if( isset( $dur['sec'] ))
4467
-      $dtend +=   $dur['sec'];
4453
+    $dateOnly         = (isset($d1['hour']) || isset($d1['min']) || isset($d1['sec'])) ? FALSE : TRUE;
4454
+    $d1['hour']       = (isset($d1['hour'])) ? $d1['hour'] : 0;
4455
+    $d1['min']        = (isset($d1['min'])) ? $d1['min'] : 0;
4456
+    $d1['sec']        = (isset($d1['sec'])) ? $d1['sec'] : 0;
4457
+    $dtend = mktime($d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year']);
4458
+    if (isset($dur['week']))
4459
+      $dtend += ($dur['week'] * 7 * 24 * 60 * 60);
4460
+    if (isset($dur['day']))
4461
+      $dtend += ($dur['day'] * 24 * 60 * 60);
4462
+    if (isset($dur['hour']))
4463
+      $dtend += ($dur['hour'] * 60 * 60);
4464
+    if (isset($dur['min']))
4465
+      $dtend += ($dur['min'] * 60);
4466
+    if (isset($dur['sec']))
4467
+      $dtend += $dur['sec'];
4468 4468
     $dtend2 = array();
4469
-    $dtend2['year']   = date('Y', $dtend );
4470
-    $dtend2['month']  = date('m', $dtend );
4471
-    $dtend2['day']    = date('d', $dtend );
4472
-    $dtend2['hour']   = date('H', $dtend );
4473
-    $dtend2['min']    = date('i', $dtend );
4474
-    $dtend2['sec']    = date('s', $dtend );
4475
-    if( isset( $d1['tz'] ))
4469
+    $dtend2['year']   = date('Y', $dtend);
4470
+    $dtend2['month']  = date('m', $dtend);
4471
+    $dtend2['day']    = date('d', $dtend);
4472
+    $dtend2['hour']   = date('H', $dtend);
4473
+    $dtend2['min']    = date('i', $dtend);
4474
+    $dtend2['sec']    = date('s', $dtend);
4475
+    if (isset($d1['tz']))
4476 4476
       $dtend2['tz']   = $d1['tz'];
4477
-    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4478
-      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
4477
+    if ($dateOnly && ((0 == $dtend2['hour']) && (0 == $dtend2['min']) && (0 == $dtend2['sec'])))
4478
+      unset($dtend2['hour'], $dtend2['min'], $dtend2['sec']);
4479 4479
     return $dtend2;
4480 4480
   }
4481 4481
 /**
@@ -4486,21 +4486,21 @@  discard block
 block discarded – undo
4486 4486
  * @param string $duration
4487 4487
  * @return array
4488 4488
  */
4489
-  function _duration_string( $duration ) {
4490
-   $duration = (string) trim( $duration );
4491
-   while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4492
-     if( 0 < strlen( $duration ))
4493
-       $duration = substr( $duration, 1 );
4489
+  function _duration_string($duration) {
4490
+   $duration = (string) trim($duration);
4491
+   while ('P' != strtoupper(substr($duration, 0, 1))) {
4492
+     if (0 < strlen($duration))
4493
+       $duration = substr($duration, 1);
4494 4494
      else
4495 4495
        return false; // no leading P !?!?
4496 4496
    }
4497
-   $duration = substr( $duration, 1 ); // skip P
4498
-   $duration = str_replace ( 't', 'T', $duration );
4499
-   $duration = str_replace ( 'T', '', $duration );
4497
+   $duration = substr($duration, 1); // skip P
4498
+   $duration = str_replace('t', 'T', $duration);
4499
+   $duration = str_replace('T', '', $duration);
4500 4500
    $output = array();
4501 4501
    $val    = null;
4502
-   for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
4503
-     switch( strtoupper( $duration{$ix} )) {
4502
+   for ($ix = 0; $ix < strlen($duration); $ix++) {
4503
+     switch (strtoupper($duration{$ix} )) {
4504 4504
       case 'W':
4505 4505
         $output['week'] = $val;
4506 4506
         $val            = null;
@@ -4522,13 +4522,13 @@  discard block
 block discarded – undo
4522 4522
         $val            = null;
4523 4523
         break;
4524 4524
       default:
4525
-        if( !ctype_digit( $duration{$ix} ))
4525
+        if (!ctype_digit($duration{$ix} ))
4526 4526
           return false; // unknown duration controll character  !?!?
4527 4527
         else
4528 4528
           $val .= $duration{$ix};
4529 4529
      }
4530 4530
    }
4531
-   return $this->_duration_array( $output );
4531
+   return $this->_duration_array($output);
4532 4532
   }
4533 4533
 /**
4534 4534
  * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue
@@ -4543,15 +4543,15 @@  discard block
 block discarded – undo
4543 4543
  * @param int $preSet optional, return value if already preset
4544 4544
  * @return int
4545 4545
  */
4546
-  function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4547
-    if( $preSet )
4546
+  function _existRem(&$array, $expkey, $expval = FALSE, $hitVal = null, $elseVal = null, $preSet = null) {
4547
+    if ($preSet)
4548 4548
       return $preSet;
4549
-    if( !is_array( $array ) || ( 0 == count( $array )))
4549
+    if (!is_array($array) || (0 == count($array)))
4550 4550
       return $elseVal;
4551
-    foreach( $array as $key => $value ) {
4552
-      if( strtoupper( $expkey ) == strtoupper( $key )) {
4553
-        if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
4554
-          unset( $array[$key] );
4551
+    foreach ($array as $key => $value) {
4552
+      if (strtoupper($expkey) == strtoupper($key)) {
4553
+        if (!$expval || (strtoupper($expval) == strtoupper($array[$key]))) {
4554
+          unset($array[$key]);
4555 4555
           return $hitVal;
4556 4556
         }
4557 4557
       }
@@ -4567,48 +4567,48 @@  discard block
 block discarded – undo
4567 4567
  * @param int     $parno, optional, default 6
4568 4568
  * @return string
4569 4569
  */
4570
-  function _format_date_time( $datetime, $parno=6 ) {
4571
-    if( !isset( $datetime['year'] )  &&
4572
-        !isset( $datetime['month'] ) &&
4573
-        !isset( $datetime['day'] )   &&
4574
-        !isset( $datetime['hour'] )  &&
4575
-        !isset( $datetime['min'] )   &&
4576
-        !isset( $datetime['sec'] ))
4577
-      return ;
4570
+  function _format_date_time($datetime, $parno = 6) {
4571
+    if (!isset($datetime['year']) &&
4572
+        !isset($datetime['month']) &&
4573
+        !isset($datetime['day']) &&
4574
+        !isset($datetime['hour']) &&
4575
+        !isset($datetime['min']) &&
4576
+        !isset($datetime['sec']))
4577
+      return;
4578 4578
     $output = null;
4579 4579
     // 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"; }
4580
-    foreach( $datetime as $dkey => $dvalue ) {
4581
-      if( 'tz' != $dkey )
4580
+    foreach ($datetime as $dkey => $dvalue) {
4581
+      if ('tz' != $dkey)
4582 4582
         $datetime[$dkey] = (integer) $dvalue;
4583 4583
     }
4584
-    $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
4585
-    if( isset( $datetime['hour'] )  ||
4586
-        isset( $datetime['min'] )   ||
4587
-        isset( $datetime['sec'] )   ||
4588
-        isset( $datetime['tz'] )) {
4589
-      if( isset( $datetime['tz'] )  &&
4590
-         !isset( $datetime['hour'] ))
4584
+    $output = date('Ymd', mktime(0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
4585
+    if (isset($datetime['hour']) ||
4586
+        isset($datetime['min']) ||
4587
+        isset($datetime['sec']) ||
4588
+        isset($datetime['tz'])) {
4589
+      if (isset($datetime['tz']) &&
4590
+         !isset($datetime['hour']))
4591 4591
         $datetime['hour'] = 0;
4592
-      if( isset( $datetime['hour'] )  &&
4593
-         !isset( $datetime['min'] ))
4592
+      if (isset($datetime['hour']) &&
4593
+         !isset($datetime['min']))
4594 4594
         $datetime['min'] = 0;
4595
-      if( isset( $datetime['hour'] )  &&
4596
-          isset( $datetime['min'] )   &&
4597
-         !isset( $datetime['sec'] ))
4595
+      if (isset($datetime['hour']) &&
4596
+          isset($datetime['min']) &&
4597
+         !isset($datetime['sec']))
4598 4598
         $datetime['sec'] = 0;
4599
-      $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600
-      $output .= date('\THis', $date );
4601
-      if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4602
-        $datetime['tz'] = trim( $datetime['tz'] );
4603
-        if( 'Z' == $datetime['tz'] )
4599
+      $date = mktime($datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600
+      $output .= date('\THis', $date);
4601
+      if (isset($datetime['tz']) && ('' < trim($datetime['tz']))) {
4602
+        $datetime['tz'] = trim($datetime['tz']);
4603
+        if ('Z' == $datetime['tz'])
4604 4604
           $output .= 'Z';
4605
-        $offset = $this->_tz2offset( $datetime['tz'] );
4606
-        if( 0 != $offset ) {
4607
-          $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608
-          $output    = date( 'Ymd\THis\Z', $date );
4605
+        $offset = $this->_tz2offset($datetime['tz']);
4606
+        if (0 != $offset) {
4607
+          $date = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608
+          $output = date('Ymd\THis\Z', $date);
4609 4609
         }
4610 4610
       }
4611
-      elseif( 7 == $parno )
4611
+      elseif (7 == $parno)
4612 4612
         $output .= 'Z';
4613 4613
     }
4614 4614
     return $output;
@@ -4621,26 +4621,26 @@  discard block
 block discarded – undo
4621 4621
  * @param array $duration ( week, day, hour, min, sec )
4622 4622
  * @return string
4623 4623
  */
4624
-  function _format_duration( $duration ) {
4625
-    if( !isset( $duration['week'] ) &&
4626
-        !isset( $duration['day'] )  &&
4627
-        !isset( $duration['hour'] ) &&
4628
-        !isset( $duration['min'] )  &&
4629
-        !isset( $duration['sec'] ))
4624
+  function _format_duration($duration) {
4625
+    if (!isset($duration['week']) &&
4626
+        !isset($duration['day']) &&
4627
+        !isset($duration['hour']) &&
4628
+        !isset($duration['min']) &&
4629
+        !isset($duration['sec']))
4630 4630
       return;
4631 4631
     $output = 'P';
4632
-    if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4632
+    if (isset($duration['week']) && (0 < $duration['week']))
4633 4633
       $output   .= $duration['week'].'W';
4634 4634
     else {
4635
-      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4635
+      if (isset($duration['day']) && (0 < $duration['day']))
4636 4636
         $output .= $duration['day'].'D';
4637
-      if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4638
-         ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4639
-         ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
4637
+      if ((isset($duration['hour']) && (0 < $duration['hour'])) ||
4638
+         (isset($duration['min']) && (0 < $duration['min'])) ||
4639
+         (isset($duration['sec']) && (0 < $duration['sec']))) {
4640 4640
         $output .= 'T';
4641
-        $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H';
4642
-        $output .= ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ? $duration['min']. 'M' : '0M';
4643
-        $output .= ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))  ? $duration['sec']. 'S' : '0S';
4641
+        $output .= (isset($duration['hour']) && (0 < $duration['hour'])) ? $duration['hour'].'H' : '0H';
4642
+        $output .= (isset($duration['min']) && (0 < $duration['min'])) ? $duration['min'].'M' : '0M';
4643
+        $output .= (isset($duration['sec']) && (0 < $duration['sec'])) ? $duration['sec'].'S' : '0S';
4644 4644
       }
4645 4645
     }
4646 4646
     return $output;
@@ -4654,24 +4654,24 @@  discard block
 block discarded – undo
4654 4654
  * @param array $recurdata
4655 4655
  * @return string
4656 4656
  */
4657
-  function _format_recur( $recurlabel, $recurdata ) {
4657
+  function _format_recur($recurlabel, $recurdata) {
4658 4658
     $output = null;
4659
-    foreach( $recurdata as $therule ) {
4660
-      if( empty( $therule['value'] )) {
4661
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
4659
+    foreach ($recurdata as $therule) {
4660
+      if (empty($therule['value'])) {
4661
+        if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($recurlabel);
4662 4662
         continue;
4663 4663
       }
4664
-      $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
4665
-      $content1  = $content2  = null;
4666
-      foreach( $therule['value'] as $rulelabel => $rulevalue ) {
4667
-        switch( $rulelabel ) {
4664
+      $attributes = (isset($therule['params'])) ? $this->_createParams($therule['params']) : null;
4665
+      $content1 = $content2 = null;
4666
+      foreach ($therule['value'] as $rulelabel => $rulevalue) {
4667
+        switch ($rulelabel) {
4668 4668
           case 'FREQ': {
4669 4669
             $content1 .= "FREQ=$rulevalue";
4670 4670
             break;
4671 4671
           }
4672 4672
           case 'UNTIL': {
4673 4673
             $content2 .= ";UNTIL=";
4674
-            $content2 .= $this->_format_date_time( $rulevalue );
4674
+            $content2 .= $this->_format_date_time($rulevalue);
4675 4675
             break;
4676 4676
           }
4677 4677
           case 'COUNT':
@@ -4689,9 +4689,9 @@  discard block
 block discarded – undo
4689 4689
           case 'BYMONTH':
4690 4690
           case 'BYSETPOS': {
4691 4691
             $content2 .= ";$rulelabel=";
4692
-            if( is_array( $rulevalue )) {
4693
-              foreach( $rulevalue as $vix => $valuePart ) {
4694
-                $content2 .= ( $vix ) ? ',' : null;
4692
+            if (is_array($rulevalue)) {
4693
+              foreach ($rulevalue as $vix => $valuePart) {
4694
+                $content2 .= ($vix) ? ',' : null;
4695 4695
                 $content2 .= $valuePart;
4696 4696
               }
4697 4697
             }
@@ -4702,12 +4702,12 @@  discard block
 block discarded – undo
4702 4702
           case 'BYDAY': {
4703 4703
             $content2 .= ";$rulelabel=";
4704 4704
             $bydaycnt = 0;
4705
-            foreach( $rulevalue as $vix => $valuePart ) {
4705
+            foreach ($rulevalue as $vix => $valuePart) {
4706 4706
               $content21 = $content22 = null;
4707
-              if( is_array( $valuePart )) {
4708
-                $content2 .= ( $bydaycnt ) ? ',' : null;
4709
-                foreach( $valuePart as $vix2 => $valuePart2 ) {
4710
-                  if( 'DAY' != strtoupper( $vix2 ))
4707
+              if (is_array($valuePart)) {
4708
+                $content2 .= ($bydaycnt) ? ',' : null;
4709
+                foreach ($valuePart as $vix2 => $valuePart2) {
4710
+                  if ('DAY' != strtoupper($vix2))
4711 4711
                       $content21 .= $valuePart2;
4712 4712
                   else
4713 4713
                     $content22 .= $valuePart2;
@@ -4716,8 +4716,8 @@  discard block
 block discarded – undo
4716 4716
                 $bydaycnt++;
4717 4717
               }
4718 4718
               else {
4719
-                $content2 .= ( $bydaycnt ) ? ',' : null;
4720
-                if( 'DAY' != strtoupper( $vix ))
4719
+                $content2 .= ($bydaycnt) ? ',' : null;
4720
+                if ('DAY' != strtoupper($vix))
4721 4721
                     $content21 .= $valuePart;
4722 4722
                 else {
4723 4723
                   $content22 .= $valuePart;
@@ -4734,7 +4734,7 @@  discard block
 block discarded – undo
4734 4734
           }
4735 4735
         }
4736 4736
       }
4737
-      $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 );
4737
+      $output .= $this->_createElement($recurlabel, $attributes, $content1.$content2);
4738 4738
     }
4739 4739
     return $output;
4740 4740
   }
@@ -4746,13 +4746,13 @@  discard block
 block discarded – undo
4746 4746
  * @param string $propertyName
4747 4747
  * @return string
4748 4748
  */
4749
-  function _formatPropertyName( $propertyName ) {
4750
-    switch( $this->format ) {
4749
+  function _formatPropertyName($propertyName) {
4750
+    switch ($this->format) {
4751 4751
       case 'xcal':
4752
-        return strtolower( $propertyName );
4752
+        return strtolower($propertyName);
4753 4753
         break;
4754 4754
       default:
4755
-        return strtoupper( $propertyName );
4755
+        return strtoupper($propertyName);
4756 4756
         break;
4757 4757
     }
4758 4758
   }
@@ -4764,25 +4764,25 @@  discard block
 block discarded – undo
4764 4764
  * @param array $input
4765 4765
  * @return bool
4766 4766
  */
4767
-  function _isArrayDate( $input ) {
4768
-    if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4767
+  function _isArrayDate($input) {
4768
+    if (isset($input['week']) || (!in_array(count($input), array(3, 6, 7))))
4769 4769
       return FALSE;
4770
-    if( 7 == count( $input ))
4770
+    if (7 == count($input))
4771 4771
       return TRUE;
4772
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4773
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4774
-    if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4772
+    if (isset($input['year']) && isset($input['month']) && isset($input['day']))
4773
+      return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']);
4774
+    if (isset($input['day']) || isset($input['hour']) || isset($input['min']) || isset($input['sec']))
4775 4775
       return FALSE;
4776
-    if( in_array( 0, $input ))
4776
+    if (in_array(0, $input))
4777 4777
       return FALSE;
4778
-    if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4778
+    if ((1970 > $input[0]) || (12 < $input[1]) || (31 < $input[2]))
4779 4779
       return FALSE;
4780
-    if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4781
-         checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4780
+    if ((isset($input[0]) && isset($input[1]) && isset($input[2])) &&
4781
+         checkdate((int) $input[1], (int) $input[2], (int) $input[0]))
4782 4782
       return TRUE;
4783
-    $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4784
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4785
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4783
+    $input = $this->_date_time_string($input[1].'/'.$input[2].'/'.$input[0], 3); //  m - d - Y
4784
+    if (isset($input['year']) && isset($input['month']) && isset($input['day']))
4785
+      return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']);
4786 4786
     return FALSE;
4787 4787
   }
4788 4788
 /**
@@ -4793,8 +4793,8 @@  discard block
 block discarded – undo
4793 4793
  * @param array $input
4794 4794
  * @return bool
4795 4795
  */
4796
-  function _isArrayTimestampDate( $input ) {
4797
-    return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ;
4796
+  function _isArrayTimestampDate($input) {
4797
+    return (is_array($input) && isset($input['timestamp'])) ? TRUE : FALSE;
4798 4798
   }
4799 4799
 /**
4800 4800
  * controll if input string contains traling UTC offset
@@ -4804,17 +4804,17 @@  discard block
 block discarded – undo
4804 4804
  * @param string $input
4805 4805
  * @return bool
4806 4806
  */
4807
-  function _isOffset( $input ) {
4808
-    $input         = trim( (string) $input );
4809
-    if( 'Z' == substr( $input, -1 ))
4807
+  function _isOffset($input) {
4808
+    $input = trim((string) $input);
4809
+    if ('Z' == substr($input, -1))
4810 4810
       return TRUE;
4811
-    elseif((   5 <= strlen( $input )) &&
4812
-       ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4813
-       (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4811
+    elseif ((5 <= strlen($input)) &&
4812
+       (in_array(substr($input, -5, 1), array('+', '-'))) &&
4813
+       ('0000' < substr($input, -4)) && ('9999' >= substr($input, -4)))
4814 4814
       return TRUE;
4815
-    elseif((    7 <= strlen( $input )) &&
4816
-       ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4817
-       ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4815
+    elseif ((7 <= strlen($input)) &&
4816
+       (in_array(substr($input, -7, 1), array('+', '-'))) &&
4817
+       ('000000' < substr($input, -6)) && ('999999' >= substr($input, -6)))
4818 4818
       return TRUE;
4819 4819
     return FALSE;
4820 4820
 
@@ -4827,15 +4827,15 @@  discard block
 block discarded – undo
4827 4827
  * @param string $propName
4828 4828
  * @return bool
4829 4829
  */
4830
-  function _notExistProp( $propName ) {
4831
-    if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
4832
-    $propName = strtolower( $propName );
4833
-    if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
4834
-    elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) return TRUE; }
4835
-    elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid ))    return TRUE; }
4836
-    elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto ))       return TRUE; }
4837
-    elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4838
-    elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
4830
+  function _notExistProp($propName) {
4831
+    if (empty($propName)) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
4832
+    $propName = strtolower($propName);
4833
+    if ('last-modified' == $propName) { if (!isset($this->lastmodified))    return TRUE; }
4834
+    elseif ('percent-complete' == $propName) { if (!isset($this->percentcomplete)) return TRUE; }
4835
+    elseif ('recurrence-id' == $propName) { if (!isset($this->recurrenceid))    return TRUE; }
4836
+    elseif ('related-to' == $propName) { if (!isset($this->relatedto))       return TRUE; }
4837
+    elseif ('request-status' == $propName) { if (!isset($this->requeststatus))   return TRUE; }
4838
+    elseif (('x-' != substr($propName, 0, 2)) && !isset($this->$propName))       return TRUE;
4839 4839
     return FALSE;
4840 4840
   }
4841 4841
 /**
@@ -4853,101 +4853,101 @@  discard block
 block discarded – undo
4853 4853
  * @return array of recurrence (start-)dates as index
4854 4854
  * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4855 4855
  */
4856
-  function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4857
-    foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
4858
-    $wdatets     = $this->_date2timestamp( $wdate );
4859
-    $startdatets = $this->_date2timestamp( $startdate );
4860
-    if( !$enddate ) {
4856
+  function _recur2date(& $result, $recur, $wdate, $startdate, $enddate = FALSE) {
4857
+    foreach ($wdate as $k => $v) if (ctype_digit($v)) $wdate[$k] = (int) $v;
4858
+    $wdatets     = $this->_date2timestamp($wdate);
4859
+    $startdatets = $this->_date2timestamp($startdate);
4860
+    if (!$enddate) {
4861 4861
       $enddate = $startdate;
4862 4862
       $enddate['year'] += 1;
4863 4863
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4864 4864
     }
4865
-    $endDatets = $this->_date2timestamp( $enddate ); // fix break
4866
-    if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4865
+    $endDatets = $this->_date2timestamp($enddate); // fix break
4866
+    if (!isset($recur['COUNT']) && !isset($recur['UNTIL']))
4867 4867
       $recur['UNTIL'] = $enddate; // create break
4868
-    if( isset( $recur['UNTIL'] )) {
4869
-      $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4870
-      if( $endDatets > $tdatets ) {
4868
+    if (isset($recur['UNTIL'])) {
4869
+      $tdatets = $this->_date2timestamp($recur['UNTIL']);
4870
+      if ($endDatets > $tdatets) {
4871 4871
         $endDatets = $tdatets; // emergency break
4872
-        $enddate   = $this->_timestamp2date( $endDatets, 6 );
4872
+        $enddate   = $this->_timestamp2date($endDatets, 6);
4873 4873
       }
4874 4874
       else
4875
-        $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4875
+        $recur['UNTIL'] = $this->_timestamp2date($endDatets, 6);
4876 4876
     }
4877
-    if( $wdatets > $endDatets ) {
4877
+    if ($wdatets > $endDatets) {
4878 4878
      //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4879 4879
       return array(); // nothing to do.. .
4880 4880
     }
4881
-    if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4881
+    if (!isset($recur['FREQ'])) // "MUST be specified.. ."
4882 4882
       $recur['FREQ'] = 'DAILY'; // ??
4883
-    $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4884
-    if( !isset( $recur['INTERVAL'] ))
4883
+    $wkst = (isset($recur['WKST']) && ('SU' == $recur['WKST'])) ? 24 * 60 * 60 : 0; // ??
4884
+    if (!isset($recur['INTERVAL']))
4885 4885
       $recur['INTERVAL'] = 1;
4886
-    $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4886
+    $countcnt = (!isset($recur['BYSETPOS'])) ? 1 : 0; // DTSTART counts as the first occurrence
4887 4887
             /* find out how to step up dates and set index for interval count */
4888 4888
     $step = array();
4889
-    if( 'YEARLY' == $recur['FREQ'] )
4889
+    if ('YEARLY' == $recur['FREQ'])
4890 4890
       $step['year']  = 1;
4891
-    elseif( 'MONTHLY' == $recur['FREQ'] )
4891
+    elseif ('MONTHLY' == $recur['FREQ'])
4892 4892
       $step['month'] = 1;
4893
-    elseif( 'WEEKLY' == $recur['FREQ'] )
4893
+    elseif ('WEEKLY' == $recur['FREQ'])
4894 4894
       $step['day']   = 7;
4895 4895
     else
4896 4896
       $step['day']   = 1;
4897
-    if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4898
-      $step = array( 'month' => 1 );
4899
-    if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
4900
-      $step = array( 'day' => 7 );
4901
-    if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4902
-      $step = array( 'day' => 1 );
4897
+    if (isset($step['year']) && isset($recur['BYMONTH']))
4898
+      $step = array('month' => 1);
4899
+    if (empty($step) && isset($recur['BYWEEKNO'])) // ??
4900
+      $step = array('day' => 7);
4901
+    if (isset($recur['BYYEARDAY']) || isset($recur['BYMONTHDAY']) || isset($recur['BYDAY']))
4902
+      $step = array('day' => 1);
4903 4903
     $intervalarr = array();
4904
-    if( 1 < $recur['INTERVAL'] ) {
4905
-      $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
4906
-      $intervalarr = array( $intervalix => 0 );
4904
+    if (1 < $recur['INTERVAL']) {
4905
+      $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst);
4906
+      $intervalarr = array($intervalix => 0);
4907 4907
     }
4908
-    if( isset( $recur['BYSETPOS'] )) { // save start date + weekno
4908
+    if (isset($recur['BYSETPOS'])) { // save start date + weekno
4909 4909
       $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array();
4910
-      $bysetposWold = (int) date( 'W', ( $wdatets + $wkst ));
4910
+      $bysetposWold = (int) date('W', ($wdatets + $wkst));
4911 4911
       $bysetposYold = $wdate['year'];
4912 4912
       $bysetposMold = $wdate['month'];
4913 4913
       $bysetposDold = $wdate['day'];
4914
-      if( is_array( $recur['BYSETPOS'] )) {
4915
-        foreach( $recur['BYSETPOS'] as $bix => $bval )
4914
+      if (is_array($recur['BYSETPOS'])) {
4915
+        foreach ($recur['BYSETPOS'] as $bix => $bval)
4916 4916
           $recur['BYSETPOS'][$bix] = (int) $bval;
4917 4917
       }
4918 4918
       else
4919
-        $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4920
-      $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4919
+        $recur['BYSETPOS'] = array((int) $recur['BYSETPOS']);
4920
+      $this->_stepdate($enddate, $endDatets, $step); // make sure to count whole last period
4921 4921
     }
4922
-    $this->_stepdate( $wdate, $wdatets, $step);
4922
+    $this->_stepdate($wdate, $wdatets, $step);
4923 4923
     $year_old     = null;
4924
-    $daynames     = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' );
4924
+    $daynames     = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
4925 4925
              /* MAIN LOOP */
4926 4926
      // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4927
-    while( TRUE ) {
4928
-      if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4927
+    while (TRUE) {
4928
+      if (isset($endDatets) && ($wdatets > $endDatets))
4929 4929
         break;
4930
-      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4930
+      if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT']))
4931 4931
         break;
4932
-      if( $year_old != $wdate['year'] ) {
4932
+      if ($year_old != $wdate['year']) {
4933 4933
         $year_old   = $wdate['year'];
4934 4934
         $daycnts    = array();
4935 4935
         $yeardays   = $weekno = 0;
4936 4936
         $yeardaycnt = array();
4937
-        for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4937
+        for ($m = 1; $m <= 12; $m++) { // count up and update up-counters
4938 4938
           $daycnts[$m] = array();
4939 4939
           $weekdaycnt = array();
4940
-          foreach( $daynames as $dn )
4940
+          foreach ($daynames as $dn)
4941 4941
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4942
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4943
-          for( $d   = 1; $d <= $mcnt; $d++ ) {
4942
+          $mcnt     = date('t', mktime(0, 0, 0, $m, 1, $wdate['year']));
4943
+          for ($d   = 1; $d <= $mcnt; $d++) {
4944 4944
             $daycnts[$m][$d] = array();
4945
-            if( isset( $recur['BYYEARDAY'] )) {
4945
+            if (isset($recur['BYYEARDAY'])) {
4946 4946
               $yeardays++;
4947 4947
               $daycnts[$m][$d]['yearcnt_up'] = $yeardays;
4948 4948
             }
4949
-            if( isset( $recur['BYDAY'] )) {
4950
-              $day    = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] ));
4949
+            if (isset($recur['BYDAY'])) {
4950
+              $day    = date('w', mktime(0, 0, 0, $m, $d, $wdate['year']));
4951 4951
               $day    = $daynames[$day];
4952 4952
               $daycnts[$m][$d]['DAY'] = $day;
4953 4953
               $weekdaycnt[$day]++;
@@ -4955,64 +4955,64 @@  discard block
 block discarded – undo
4955 4955
               $yeardaycnt[$day]++;
4956 4956
               $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4957 4957
             }
4958
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4959
-              $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
4958
+            if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY'))
4959
+              $daycnts[$m][$d]['weekno_up'] = (int) date('W', mktime(0, 0, $wkst, $m, $d, $wdate['year']));
4960 4960
           }
4961 4961
         }
4962 4962
         $daycnt = 0;
4963 4963
         $yeardaycnt = array();
4964
-        if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4964
+        if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) {
4965 4965
           $weekno = null;
4966
-          for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4967
-            if( !$weekno )
4966
+          for ($d = 31; $d > 25; $d--) { // get last weekno for year
4967
+            if (!$weekno)
4968 4968
               $weekno = $daycnts[12][$d]['weekno_up'];
4969
-            elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
4969
+            elseif ($weekno < $daycnts[12][$d]['weekno_up']) {
4970 4970
               $weekno = $daycnts[12][$d]['weekno_up'];
4971 4971
               break;
4972 4972
             }
4973 4973
           }
4974 4974
         }
4975
-        for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
4975
+        for ($m = 12; $m > 0; $m--) { // count down and update down-counters
4976 4976
           $weekdaycnt = array();
4977
-          foreach( $daynames as $dn )
4977
+          foreach ($daynames as $dn)
4978 4978
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4979 4979
           $monthcnt = 0;
4980
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4981
-          for( $d   = $mcnt; $d > 0; $d-- ) {
4982
-            if( isset( $recur['BYYEARDAY'] )) {
4980
+          $mcnt     = date('t', mktime(0, 0, 0, $m, 1, $wdate['year']));
4981
+          for ($d   = $mcnt; $d > 0; $d--) {
4982
+            if (isset($recur['BYYEARDAY'])) {
4983 4983
               $daycnt -= 1;
4984 4984
               $daycnts[$m][$d]['yearcnt_down'] = $daycnt;
4985 4985
             }
4986
-            if( isset( $recur['BYMONTHDAY'] )) {
4986
+            if (isset($recur['BYMONTHDAY'])) {
4987 4987
               $monthcnt -= 1;
4988 4988
               $daycnts[$m][$d]['monthcnt_down'] = $monthcnt;
4989 4989
             }
4990
-            if( isset( $recur['BYDAY'] )) {
4991
-              $day  = $daycnts[$m][$d]['DAY'];
4990
+            if (isset($recur['BYDAY'])) {
4991
+              $day = $daycnts[$m][$d]['DAY'];
4992 4992
               $weekdaycnt[$day] -= 1;
4993 4993
               $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day];
4994 4994
               $yeardaycnt[$day] -= 1;
4995 4995
               $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4996 4996
             }
4997
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4997
+            if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY'))
4998 4998
               $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
4999 4999
           }
5000 5000
         }
5001 5001
       }
5002 5002
             /* check interval */
5003
-      if( 1 < $recur['INTERVAL'] ) {
5003
+      if (1 < $recur['INTERVAL']) {
5004 5004
             /* create interval index */
5005
-        $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
5005
+        $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst);
5006 5006
             /* check interval */
5007
-        $currentKey = array_keys( $intervalarr );
5008
-        $currentKey = end( $currentKey ); // get last index
5009
-        if( $currentKey != $intervalix )
5010
-          $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5011
-        if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5012
-           ( 0 != $intervalarr[$intervalix] )) {
5007
+        $currentKey = array_keys($intervalarr);
5008
+        $currentKey = end($currentKey); // get last index
5009
+        if ($currentKey != $intervalix)
5010
+          $intervalarr = array($intervalix => ($intervalarr[$currentKey] + 1));
5011
+        if (($recur['INTERVAL'] != $intervalarr[$intervalix]) &&
5012
+           (0 != $intervalarr[$intervalix])) {
5013 5013
             /* step up date */
5014 5014
     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5015
-          $this->_stepdate( $wdate, $wdatets, $step);
5015
+          $this->_stepdate($wdate, $wdatets, $step);
5016 5016
           continue;
5017 5017
         }
5018 5018
         else // continue within the selected interval
@@ -5020,69 +5020,69 @@  discard block
 block discarded – undo
5020 5020
    //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5021 5021
       }
5022 5022
       $updateOK = TRUE;
5023
-      if( $updateOK && isset( $recur['BYMONTH'] ))
5024
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5023
+      if ($updateOK && isset($recur['BYMONTH']))
5024
+        $updateOK = $this->_recurBYcntcheck($recur['BYMONTH']
5025 5025
                                            , $wdate['month']
5026 5026
                                            ,($wdate['month'] - 13));
5027
-      if( $updateOK && isset( $recur['BYWEEKNO'] ))
5028
-        $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5027
+      if ($updateOK && isset($recur['BYWEEKNO']))
5028
+        $updateOK = $this->_recurBYcntcheck($recur['BYWEEKNO']
5029 5029
                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5030
-                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5031
-      if( $updateOK && isset( $recur['BYYEARDAY'] ))
5032
-        $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5030
+                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_down']);
5031
+      if ($updateOK && isset($recur['BYYEARDAY']))
5032
+        $updateOK = $this->_recurBYcntcheck($recur['BYYEARDAY']
5033 5033
                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5034
-                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5035
-      if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5036
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5034
+                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down']);
5035
+      if ($updateOK && isset($recur['BYMONTHDAY']))
5036
+        $updateOK = $this->_recurBYcntcheck($recur['BYMONTHDAY']
5037 5037
                                            , $wdate['day']
5038
-                                           , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5038
+                                           , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down']);
5039 5039
     //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5040
-      if( $updateOK && isset( $recur['BYDAY'] )) {
5040
+      if ($updateOK && isset($recur['BYDAY'])) {
5041 5041
         $updateOK = FALSE;
5042 5042
         $m = $wdate['month'];
5043 5043
         $d = $wdate['day'];
5044
-        if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5045
-          $daynoexists = $daynosw = $daynamesw =  FALSE;
5046
-          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5044
+        if (isset($recur['BYDAY']['DAY'])) { // single day, opt with year/month day order no
5045
+          $daynoexists = $daynosw = $daynamesw = FALSE;
5046
+          if ($recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'])
5047 5047
             $daynamesw = TRUE;
5048
-          if( isset( $recur['BYDAY'][0] )) {
5048
+          if (isset($recur['BYDAY'][0])) {
5049 5049
             $daynoexists = TRUE;
5050
-            if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5051
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5050
+            if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || isset($recur['BYMONTH']))
5051
+              $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0]
5052 5052
                                                 , $daycnts[$m][$d]['monthdayno_up']
5053
-                                                , $daycnts[$m][$d]['monthdayno_down'] );
5054
-            elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5055
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5053
+                                                , $daycnts[$m][$d]['monthdayno_down']);
5054
+            elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY'))
5055
+              $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0]
5056 5056
                                                 , $daycnts[$m][$d]['yeardayno_up']
5057
-                                                , $daycnts[$m][$d]['yeardayno_down'] );
5057
+                                                , $daycnts[$m][$d]['yeardayno_down']);
5058 5058
           }
5059
-          if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5060
-             ( !$daynoexists && !$daynosw && $daynamesw )) {
5059
+          if (($daynoexists && $daynosw && $daynamesw) ||
5060
+             (!$daynoexists && !$daynosw && $daynamesw)) {
5061 5061
             $updateOK = TRUE;
5062 5062
           }
5063 5063
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5064 5064
         }
5065 5065
         else {
5066
-          foreach( $recur['BYDAY'] as $bydayvalue ) {
5066
+          foreach ($recur['BYDAY'] as $bydayvalue) {
5067 5067
             $daynoexists = $daynosw = $daynamesw = FALSE;
5068
-            if( isset( $bydayvalue['DAY'] ) &&
5069
-                     ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5068
+            if (isset($bydayvalue['DAY']) &&
5069
+                     ($bydayvalue['DAY'] == $daycnts[$m][$d]['DAY']))
5070 5070
               $daynamesw = TRUE;
5071
-            if( isset( $bydayvalue[0] )) {
5071
+            if (isset($bydayvalue[0])) {
5072 5072
               $daynoexists = TRUE;
5073
-              if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5074
-                   isset( $recur['BYMONTH'] ))
5075
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5073
+              if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) ||
5074
+                   isset($recur['BYMONTH']))
5075
+                $daynosw = $this->_recurBYcntcheck($bydayvalue['0']
5076 5076
                                                   , $daycnts[$m][$d]['monthdayno_up']
5077
-                                                  , $daycnts[$m][$d]['monthdayno_down'] );
5078
-              elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5079
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5077
+                                                  , $daycnts[$m][$d]['monthdayno_down']);
5078
+              elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY'))
5079
+                $daynosw = $this->_recurBYcntcheck($bydayvalue['0']
5080 5080
                                                   , $daycnts[$m][$d]['yeardayno_up']
5081
-                                                  , $daycnts[$m][$d]['yeardayno_down'] );
5081
+                                                  , $daycnts[$m][$d]['yeardayno_down']);
5082 5082
             }
5083 5083
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5084
-            if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5085
-               ( !$daynoexists && !$daynosw && $daynamesw )) {
5084
+            if (($daynoexists && $daynosw && $daynamesw) ||
5085
+               (!$daynoexists && !$daynosw && $daynamesw)) {
5086 5086
               $updateOK = TRUE;
5087 5087
               break;
5088 5088
             }
@@ -5091,25 +5091,25 @@  discard block
 block discarded – undo
5091 5091
       }
5092 5092
       //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ###
5093 5093
             /* check BYSETPOS */
5094
-      if( $updateOK ) {
5095
-        if( isset( $recur['BYSETPOS'] ) &&
5096
-          ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5097
-          if( isset( $recur['WEEKLY'] )) {
5098
-            if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5094
+      if ($updateOK) {
5095
+        if (isset($recur['BYSETPOS']) &&
5096
+          (in_array($recur['FREQ'], array('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY')))) {
5097
+          if (isset($recur['WEEKLY'])) {
5098
+            if ($bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'])
5099 5099
               $bysetposw1[] = $wdatets;
5100 5100
             else
5101 5101
               $bysetposw2[] = $wdatets;
5102 5102
           }
5103 5103
           else {
5104
-            if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5105
-                                            ( $bysetposYold == $wdate['year'] ))   ||
5106
-               ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
5107
-                                           (( $bysetposYold == $wdate['year'] )  &&
5108
-                                            ( $bysetposMold == $wdate['month'] ))) ||
5109
-               ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
5110
-                                           (( $bysetposYold == $wdate['year'] )  &&
5111
-                                            ( $bysetposMold == $wdate['month'])  &&
5112
-                                            ( $bysetposDold == $wdate['sday'] ))))
5104
+            if ((isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) &&
5105
+                                            ($bysetposYold == $wdate['year'])) ||
5106
+               (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) &&
5107
+                                           (($bysetposYold == $wdate['year']) &&
5108
+                                            ($bysetposMold == $wdate['month']))) ||
5109
+               (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) &&
5110
+                                           (($bysetposYold == $wdate['year']) &&
5111
+                                            ($bysetposMold == $wdate['month']) &&
5112
+                                            ($bysetposDold == $wdate['sday']))))
5113 5113
               $bysetposymd1[] = $wdatets;
5114 5114
             else
5115 5115
               $bysetposymd2[] = $wdatets;
@@ -5118,7 +5118,7 @@  discard block
 block discarded – undo
5118 5118
         else {
5119 5119
             /* update result array if BYSETPOS is set */
5120 5120
           $countcnt++;
5121
-          if( $startdatets <= $wdatets ) { // only output within period
5121
+          if ($startdatets <= $wdatets) { // only output within period
5122 5122
             $result[$wdatets] = TRUE;
5123 5123
           //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
5124 5124
           }
@@ -5127,39 +5127,39 @@  discard block
 block discarded – undo
5127 5127
         }
5128 5128
       }
5129 5129
             /* step up date */
5130
-      $this->_stepdate( $wdate, $wdatets, $step);
5130
+      $this->_stepdate($wdate, $wdatets, $step);
5131 5131
             /* check if BYSETPOS is set for updating result array */
5132
-      if( $updateOK && isset( $recur['BYSETPOS'] )) {
5132
+      if ($updateOK && isset($recur['BYSETPOS'])) {
5133 5133
         $bysetpos       = FALSE;
5134
-        if( isset( $recur['FREQ'] ) && ( 'YEARLY'  == $recur['FREQ'] ) &&
5135
-          ( $bysetposYold != $wdate['year'] )) {
5134
+        if (isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) &&
5135
+          ($bysetposYold != $wdate['year'])) {
5136 5136
           $bysetpos     = TRUE;
5137 5137
           $bysetposYold = $wdate['year'];
5138 5138
         }
5139
-        elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5140
-         (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5139
+        elseif (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ'] &&
5140
+         (($bysetposYold != $wdate['year']) || ($bysetposMold != $wdate['month'])))) {
5141 5141
           $bysetpos     = TRUE;
5142 5142
           $bysetposYold = $wdate['year'];
5143 5143
           $bysetposMold = $wdate['month'];
5144 5144
         }
5145
-        elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5146
-          $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147
-          if( $bysetposWold != $weekno ) {
5145
+        elseif (isset($recur['FREQ']) && ('WEEKLY' == $recur['FREQ'])) {
5146
+          $weekno = (int) date('W', mktime(0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147
+          if ($bysetposWold != $weekno) {
5148 5148
             $bysetposWold = $weekno;
5149 5149
             $bysetpos     = TRUE;
5150 5150
           }
5151 5151
         }
5152
-        elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5153
-         (( $bysetposYold != $wdate['year'] )  ||
5154
-          ( $bysetposMold != $wdate['month'] ) ||
5155
-          ( $bysetposDold != $wdate['sday'] ))) {
5152
+        elseif (isset($recur['FREQ']) && ('DAILY' == $recur['FREQ']) &&
5153
+         (($bysetposYold != $wdate['year']) ||
5154
+          ($bysetposMold != $wdate['month']) ||
5155
+          ($bysetposDold != $wdate['sday']))) {
5156 5156
           $bysetpos     = TRUE;
5157 5157
           $bysetposYold = $wdate['year'];
5158 5158
           $bysetposMold = $wdate['month'];
5159 5159
           $bysetposDold = $wdate['day'];
5160 5160
         }
5161
-        if( $bysetpos ) {
5162
-          if( isset( $recur['BYWEEKNO'] )) {
5161
+        if ($bysetpos) {
5162
+          if (isset($recur['BYWEEKNO'])) {
5163 5163
             $bysetposarr1 = & $bysetposw1;
5164 5164
             $bysetposarr2 = & $bysetposw2;
5165 5165
           }
@@ -5167,18 +5167,18 @@  discard block
 block discarded – undo
5167 5167
             $bysetposarr1 = & $bysetposymd1;
5168 5168
             $bysetposarr2 = & $bysetposymd2;
5169 5169
           }
5170
-          foreach( $recur['BYSETPOS'] as $ix ) {
5171
-            if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5172
-              $ix = ( count( $bysetposarr1 ) + $ix + 1);
5170
+          foreach ($recur['BYSETPOS'] as $ix) {
5171
+            if (0 > $ix) // both positive and negative BYSETPOS allowed
5172
+              $ix = (count($bysetposarr1) + $ix + 1);
5173 5173
             $ix--;
5174
-            if( isset( $bysetposarr1[$ix] )) {
5175
-              if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
5174
+            if (isset($bysetposarr1[$ix])) {
5175
+              if ($startdatets <= $bysetposarr1[$ix]) { // only output within period
5176 5176
                 $result[$bysetposarr1[$ix]] = TRUE;
5177 5177
        //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test
5178 5178
               }
5179 5179
               $countcnt++;
5180 5180
             }
5181
-            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5181
+            if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT']))
5182 5182
               break;
5183 5183
           }
5184 5184
           $bysetposarr1 = $bysetposarr2;
@@ -5187,18 +5187,18 @@  discard block
 block discarded – undo
5187 5187
       }
5188 5188
     }
5189 5189
   }
5190
-  function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5191
-    if( is_array( $BYvalue ) &&
5192
-      ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5190
+  function _recurBYcntcheck($BYvalue, $upValue, $downValue) {
5191
+    if (is_array($BYvalue) &&
5192
+      (in_array($upValue, $BYvalue) || in_array($downValue, $BYvalue)))
5193 5193
       return TRUE;
5194
-    elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5194
+    elseif (($BYvalue == $upValue) || ($BYvalue == $downValue))
5195 5195
       return TRUE;
5196 5196
     else
5197 5197
       return FALSE;
5198 5198
   }
5199
-  function _recurIntervalIx( $freq, $date, $wkst ) {
5199
+  function _recurIntervalIx($freq, $date, $wkst) {
5200 5200
             /* create interval index */
5201
-    switch( $freq ) {
5201
+    switch ($freq) {
5202 5202
       case 'YEARLY':
5203 5203
         $intervalix = $date['year'];
5204 5204
         break;
@@ -5206,8 +5206,8 @@  discard block
 block discarded – undo
5206 5206
         $intervalix = $date['year'].'-'.$date['month'];
5207 5207
         break;
5208 5208
       case 'WEEKLY':
5209
-        $wdatets    = $this->_date2timestamp( $date );
5210
-        $intervalix = (int) date( 'W', ( $wdatets + $wkst ));
5209
+        $wdatets    = $this->_date2timestamp($date);
5210
+        $intervalix = (int) date('W', ($wdatets + $wkst));
5211 5211
        break;
5212 5212
       case 'DAILY':
5213 5213
            default:
@@ -5224,22 +5224,22 @@  discard block
 block discarded – undo
5224 5224
  * @param array $rexrule
5225 5225
  * @return array
5226 5226
  */
5227
-  function _setRexrule( $rexrule ) {
5228
-    $input          = array();
5229
-    if( empty( $rexrule ))
5227
+  function _setRexrule($rexrule) {
5228
+    $input = array();
5229
+    if (empty($rexrule))
5230 5230
       return $input;
5231
-    foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5232
-      $rexrulelabel = strtoupper( $rexrulelabel );
5233
-      if( 'UNTIL'  != $rexrulelabel )
5231
+    foreach ($rexrule as $rexrulelabel => $rexrulevalue) {
5232
+      $rexrulelabel = strtoupper($rexrulelabel);
5233
+      if ('UNTIL' != $rexrulelabel)
5234 5234
         $input[$rexrulelabel]   = $rexrulevalue;
5235 5235
       else {
5236
-        if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5237
-          $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5238
-        elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5239
-          $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5240
-        elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5241
-          $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5242
-        if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5236
+        if ($this->_isArrayTimestampDate($rexrulevalue)) // timestamp date
5237
+          $input[$rexrulelabel] = $this->_timestamp2date($rexrulevalue, 6);
5238
+        elseif ($this->_isArrayDate($rexrulevalue)) // date-time
5239
+          $input[$rexrulelabel] = $this->_date_time_array($rexrulevalue, 6);
5240
+        elseif (8 <= strlen(trim($rexrulevalue))) // ex. 2006-08-03 10:12:18
5241
+          $input[$rexrulelabel] = $this->_date_time_string($rexrulevalue);
5242
+        if ((3 < count($input[$rexrulelabel])) && !isset($input[$rexrulelabel]['tz']))
5243 5243
           $input[$rexrulelabel]['tz'] = 'Z';
5244 5244
       }
5245 5245
     }
@@ -5260,85 +5260,85 @@  discard block
 block discarded – undo
5260 5260
  * @param string $caller optional
5261 5261
  * @return array
5262 5262
  */
5263
-  function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) {
5263
+  function _setDate($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE, $caller = null) {
5264 5264
     $input = $parno = null;
5265
-    $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5266
-    if( $this->_isArrayDate( $year )) {
5267
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5268
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5269
-      if( isset( $input['params']['TZID'] )) {
5265
+    $localtime = (('dtstart' == $caller) && in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE;
5266
+    if ($this->_isArrayDate($year)) {
5267
+      if ($localtime) unset ($month['VALUE'], $month['TZID']);
5268
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5269
+      if (isset($input['params']['TZID'])) {
5270 5270
         $input['params']['VALUE'] = 'DATE-TIME';
5271
-        unset( $year['tz'] );
5271
+        unset($year['tz']);
5272 5272
       }
5273
-      $hitval          = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6;
5274
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5275
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5276
-      $input['value']  = $this->_date_time_array( $year, $parno );
5277
-    }
5278
-    elseif( $this->_isArrayTimestampDate( $year )) {
5279
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5280
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5281
-      if( isset( $input['params']['TZID'] )) {
5273
+      $hitval          = ((!empty($year['tz']) || !empty($year[6]))) ? 7 : 6;
5274
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval);
5275
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, count($year), $parno);
5276
+      $input['value']  = $this->_date_time_array($year, $parno);
5277
+    }
5278
+    elseif ($this->_isArrayTimestampDate($year)) {
5279
+      if ($localtime) unset ($month['VALUE'], $month['TZID']);
5280
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5281
+      if (isset($input['params']['TZID'])) {
5282 5282
         $input['params']['VALUE'] = 'DATE-TIME';
5283
-        unset( $year['tz'] );
5283
+        unset($year['tz']);
5284 5284
       }
5285
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5286
-      $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5287
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5288
-      $input['value']  = $this->_timestamp2date( $year, $parno );
5289
-    }
5290
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5291
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5292
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5293
-      if( isset( $input['params']['TZID'] )) {
5285
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE', 3);
5286
+      $hitval          = (isset($year['tz'])) ? 7 : 6;
5287
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno);
5288
+      $input['value']  = $this->_timestamp2date($year, $parno);
5289
+    }
5290
+    elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18
5291
+      if ($localtime) unset ($month['VALUE'], $month['TZID']);
5292
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5293
+      if (isset($input['params']['TZID'])) {
5294 5294
         $input['params']['VALUE'] = 'DATE-TIME';
5295 5295
         $parno = 6;
5296 5296
       }
5297
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5298
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5299
-      $input['value']  = $this->_date_time_string( $year, $parno );
5297
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7, $parno);
5298
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, $parno, $parno);
5299
+      $input['value']  = $this->_date_time_string($year, $parno);
5300 5300
     }
5301 5301
     else {
5302
-      if( is_array( $params )) {
5303
-        if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5304
-        $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5302
+      if (is_array($params)) {
5303
+        if ($localtime) unset ($params['VALUE'], $params['TZID']);
5304
+        $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME'));
5305 5305
       }
5306
-      elseif( is_array( $tz )) {
5307
-        $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5306
+      elseif (is_array($tz)) {
5307
+        $input['params'] = $this->_setParams($tz, array('VALUE' => 'DATE-TIME'));
5308 5308
         $tz = FALSE;
5309 5309
       }
5310
-      elseif( is_array( $hour )) {
5311
-        $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5310
+      elseif (is_array($hour)) {
5311
+        $input['params'] = $this->_setParams($hour, array('VALUE' => 'DATE-TIME'));
5312 5312
         $hour = $min = $sec = $tz = FALSE;
5313 5313
       }
5314
-      if( isset( $input['params']['TZID'] )) {
5314
+      if (isset($input['params']['TZID'])) {
5315 5315
         $tz            = null;
5316 5316
         $input['params']['VALUE'] = 'DATE-TIME';
5317 5317
       }
5318
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5319
-      $hitval          = ( !empty( $tz )) ? 7 : 6;
5320
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno );
5321
-      $input['value']  = array( 'year'  => $year, 'month' => $month, 'day'   => $day );
5322
-      if( 3 != $parno ) {
5323
-        $input['value']['hour'] = ( $hour ) ? $hour : '0';
5324
-        $input['value']['min']  = ( $min )  ? $min  : '0';
5325
-        $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5326
-        if( !empty( $tz ))
5318
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE', 3);
5319
+      $hitval          = (!empty($tz)) ? 7 : 6;
5320
+      $parno           = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno);
5321
+      $input['value']  = array('year'  => $year, 'month' => $month, 'day'   => $day);
5322
+      if (3 != $parno) {
5323
+        $input['value']['hour'] = ($hour) ? $hour : '0';
5324
+        $input['value']['min']  = ($min) ? $min : '0';
5325
+        $input['value']['sec']  = ($sec) ? $sec : '0';
5326
+        if (!empty($tz))
5327 5327
           $input['value']['tz'] = $tz;
5328 5328
       }
5329 5329
     }
5330
-    if( 3 == $parno ) {
5330
+    if (3 == $parno) {
5331 5331
       $input['params']['VALUE'] = 'DATE';
5332
-      unset( $input['value']['tz'] );
5333
-      unset( $input['params']['TZID'] );
5332
+      unset($input['value']['tz']);
5333
+      unset($input['params']['TZID']);
5334 5334
     }
5335
-    elseif( isset( $input['params']['TZID'] ))
5336
-      unset( $input['value']['tz'] );
5337
-    if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5338
-    if( isset( $input['value']['tz'] ))
5335
+    elseif (isset($input['params']['TZID']))
5336
+      unset($input['value']['tz']);
5337
+    if ($localtime) unset($input['value']['tz'], $input['params']['TZID']);
5338
+    if (isset($input['value']['tz']))
5339 5339
       $input['value']['tz'] = (string) $input['value']['tz'];
5340
-    if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5341
-      ( !$this->_isOffset( $input['value']['tz'] )))
5340
+    if (!empty($input['value']['tz']) && ('Z' != $input['value']['tz']) &&
5341
+      (!$this->_isOffset($input['value']['tz'])))
5342 5342
       $input['params']['TZID'] = $input['value']['tz'];
5343 5343
     return $input;
5344 5344
   }
@@ -5356,37 +5356,37 @@  discard block
 block discarded – undo
5356 5356
  * @param array $params optional
5357 5357
  * @return array
5358 5358
  */
5359
-  function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
5359
+  function _setDate2($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) {
5360 5360
     $input = null;
5361
-    if( $this->_isArrayDate( $year )) {
5362
-      $input['value']  = $this->_date_time_array( $year, 7 );
5363
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5361
+    if ($this->_isArrayDate($year)) {
5362
+      $input['value']  = $this->_date_time_array($year, 7);
5363
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5364 5364
     }
5365
-    elseif( $this->_isArrayTimestampDate( $year )) {
5366
-      $input['value']  = $this->_timestamp2date( $year, 7 );
5367
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5365
+    elseif ($this->_isArrayTimestampDate($year)) {
5366
+      $input['value']  = $this->_timestamp2date($year, 7);
5367
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5368 5368
     }
5369
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5370
-      $input['value']  = $this->_date_time_string( $year, 7 );
5371
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5369
+    elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18
5370
+      $input['value']  = $this->_date_time_string($year, 7);
5371
+      $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME'));
5372 5372
     }
5373 5373
     else {
5374
-      $input['value']  = array( 'year'  => $year
5374
+      $input['value']  = array('year'  => $year
5375 5375
                               , 'month' => $month
5376 5376
                               , 'day'   => $day
5377 5377
                               , 'hour'  => $hour
5378 5378
                               , 'min'   => $min
5379
-                              , 'sec'   => $sec );
5380
-      $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5379
+                              , 'sec'   => $sec);
5380
+      $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME'));
5381 5381
     }
5382
-    $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5383
-    if( !isset( $input['value']['hour'] ))
5382
+    $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7); // remove default
5383
+    if (!isset($input['value']['hour']))
5384 5384
       $input['value']['hour'] = 0;
5385
-    if( !isset( $input['value']['min'] ))
5385
+    if (!isset($input['value']['min']))
5386 5386
       $input['value']['min'] = 0;
5387
-    if( !isset( $input['value']['sec'] ))
5387
+    if (!isset($input['value']['sec']))
5388 5388
       $input['value']['sec'] = 0;
5389
-    if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5389
+    if (!isset($input['value']['tz']) || !$this->_isOffset($input['value']['tz']))
5390 5390
       $input['value']['tz'] = 'Z';
5391 5391
     return $input;
5392 5392
   }
@@ -5402,18 +5402,18 @@  discard block
 block discarded – undo
5402 5402
  * @param int $index
5403 5403
  * @return void
5404 5404
  */
5405
-  function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5406
-    if( !is_array( $valArr )) $valArr = array();
5407
-    if( $index )
5405
+  function _setMval(& $valArr, $value, $params = FALSE, $defaults = FALSE, $index = FALSE) {
5406
+    if (!is_array($valArr)) $valArr = array();
5407
+    if ($index)
5408 5408
       $index = $index - 1;
5409
-    elseif( 0 < count( $valArr )) {
5410
-      $index = end( array_keys( $valArr ));
5409
+    elseif (0 < count($valArr)) {
5410
+      $index = end(array_keys($valArr));
5411 5411
       $index += 1;
5412 5412
     }
5413 5413
     else
5414 5414
       $index = 0;
5415
-    $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5416
-    ksort( $valArr );
5415
+    $valArr[$index] = array('value' => $value, 'params' => $this->_setParams($params, $defaults));
5416
+    ksort($valArr);
5417 5417
   }
5418 5418
 /**
5419 5419
  * set input (formatted) parameters- component property attributes
@@ -5426,31 +5426,31 @@  discard block
 block discarded – undo
5426 5426
  * @param array $defaults
5427 5427
  * @return array
5428 5428
  */
5429
-  function _setParams( $params, $defaults=FALSE ) {
5430
-    if( !is_array( $params))
5429
+  function _setParams($params, $defaults = FALSE) {
5430
+    if (!is_array($params))
5431 5431
       $params = array();
5432 5432
     $input = array();
5433
-    foreach( $params as $paramKey => $paramValue ) {
5434
-      if( is_array( $paramValue )) {
5435
-        foreach( $paramValue as $pkey => $pValue ) {
5436
-          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5437
-            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
5433
+    foreach ($params as $paramKey => $paramValue) {
5434
+      if (is_array($paramValue)) {
5435
+        foreach ($paramValue as $pkey => $pValue) {
5436
+          if (('"' == substr($pValue, 0, 1)) && ('"' == substr($pValue, -1)))
5437
+            $paramValue[$pkey] = substr($pValue, 1, (strlen($pValue) - 2));
5438 5438
         }
5439 5439
       }
5440
-      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5441
-        $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5442
-      if( 'VALUE' == strtoupper( $paramKey ))
5443
-        $input['VALUE']                 = strtoupper( $paramValue );
5440
+      elseif (('"' == substr($paramValue, 0, 1)) && ('"' == substr($paramValue, -1)))
5441
+        $paramValue = substr($paramValue, 1, (strlen($paramValue) - 2));
5442
+      if ('VALUE' == strtoupper($paramKey))
5443
+        $input['VALUE']                 = strtoupper($paramValue);
5444 5444
       else
5445
-        $input[strtoupper( $paramKey )] = $paramValue;
5445
+        $input[strtoupper($paramKey)] = $paramValue;
5446 5446
     }
5447
-    if( is_array( $defaults )) {
5448
-      foreach( $defaults as $paramKey => $paramValue ) {
5449
-        if( !isset( $input[$paramKey] ))
5447
+    if (is_array($defaults)) {
5448
+      foreach ($defaults as $paramKey => $paramValue) {
5449
+        if (!isset($input[$paramKey]))
5450 5450
           $input[$paramKey] = $paramValue;
5451 5451
       }
5452 5452
     }
5453
-    return (0 < count( $input )) ? $input : null;
5453
+    return (0 < count($input)) ? $input : null;
5454 5454
   }
5455 5455
 /**
5456 5456
  * step date, return updated date, array and timpstamp
@@ -5462,13 +5462,13 @@  discard block
 block discarded – undo
5462 5462
  * @param array $step, default array( 'day' => 1 )
5463 5463
  * @return void
5464 5464
  */
5465
-  function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5466
-    foreach( $step as $stepix => $stepvalue )
5465
+  function _stepdate(&$date, &$timestamp, $step = array('day' => 1)) {
5466
+    foreach ($step as $stepix => $stepvalue)
5467 5467
       $date[$stepix] += $stepvalue;
5468
-    $timestamp  = $this->_date2timestamp( $date );
5469
-    $date       = $this->_timestamp2date( $timestamp, 6 );
5470
-    foreach( $date as $k => $v ) {
5471
-      if( ctype_digit( $v ))
5468
+    $timestamp  = $this->_date2timestamp($date);
5469
+    $date       = $this->_timestamp2date($timestamp, 6);
5470
+    foreach ($date as $k => $v) {
5471
+      if (ctype_digit($v))
5472 5472
         $date[$k] = (int) $v;
5473 5473
     }
5474 5474
   }
@@ -5481,20 +5481,20 @@  discard block
 block discarded – undo
5481 5481
  * @param int $parno
5482 5482
  * @return array
5483 5483
  */
5484
-  function _timestamp2date( $timestamp, $parno=6 ) {
5485
-    if( is_array( $timestamp )) {
5486
-      if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5484
+  function _timestamp2date($timestamp, $parno = 6) {
5485
+    if (is_array($timestamp)) {
5486
+      if ((7 == $parno) && !empty($timestamp['tz']))
5487 5487
         $tz = $timestamp['tz'];
5488 5488
       $timestamp = $timestamp['timestamp'];
5489 5489
     }
5490
-    $output = array( 'year'  => date( 'Y', $timestamp )
5491
-                   , 'month' => date( 'm', $timestamp )
5492
-                   , 'day'   => date( 'd', $timestamp ));
5493
-    if( 3 != $parno ) {
5494
-             $output['hour'] =  date( 'H', $timestamp );
5495
-             $output['min']  =  date( 'i', $timestamp );
5496
-             $output['sec']  =  date( 's', $timestamp );
5497
-      if( isset( $tz ))
5490
+    $output = array('year'  => date('Y', $timestamp)
5491
+                   , 'month' => date('m', $timestamp)
5492
+                   , 'day'   => date('d', $timestamp));
5493
+    if (3 != $parno) {
5494
+             $output['hour'] = date('H', $timestamp);
5495
+             $output['min']  = date('i', $timestamp);
5496
+             $output['sec']  = date('s', $timestamp);
5497
+      if (isset($tz))
5498 5498
         $output['tz'] = $tz;
5499 5499
     }
5500 5500
     return $output;
@@ -5507,19 +5507,19 @@  discard block
 block discarded – undo
5507 5507
  * @param string $offset
5508 5508
  * @return integer
5509 5509
  */
5510
-  function _tz2offset( $tz ) {
5511
-    $tz           = trim( (string) $tz );
5510
+  function _tz2offset($tz) {
5511
+    $tz           = trim((string) $tz);
5512 5512
     $offset       = 0;
5513
-    if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5514
-       ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5515
-       (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5516
-           (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5513
+    if (((5 != strlen($tz)) && (7 != strlen($tz))) ||
5514
+       (('+' != substr($tz, 0, 1)) && ('-' != substr($tz, 0, 1))) ||
5515
+       (('0000' >= substr($tz, 1, 4)) && ('9999' < substr($tz, 1, 4))) ||
5516
+           ((7 == strlen($tz)) && ('00' > substr($tz, 5, 2)) && ('99' < substr($tz, 5, 2))))
5517 5517
       return $offset;
5518
-    $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5519
-    $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5520
-    $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
5518
+    $hours2sec    = (int) substr($tz, 1, 2) * 3600;
5519
+    $min2sec      = (int) substr($tz, 3, 2) * 60;
5520
+    $sec          = (7 == strlen($tz)) ? (int) substr($tz, -2) : '00';
5521 5521
     $offset       = $hours2sec + $min2sec + $sec;
5522
-    $offset       = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset;
5522
+    $offset       = ('-' == substr($tz, 0, 1)) ? $offset : -1 * $offset;
5523 5523
     return $offset;
5524 5524
   }
5525 5525
 /*********************************************************************************/
@@ -5532,24 +5532,24 @@  discard block
 block discarded – undo
5532 5532
  * @param string $config
5533 5533
  * @return value
5534 5534
  */
5535
-  function getConfig( $config ) {
5536
-    switch( strtoupper( $config )) {
5535
+  function getConfig($config) {
5536
+    switch (strtoupper($config)) {
5537 5537
       case 'ALLOWEMPTY':
5538 5538
         return $this->allowEmpty;
5539 5539
         break;
5540 5540
       case 'COMPSINFO':
5541
-        unset( $this->compix );
5541
+        unset($this->compix);
5542 5542
         $info = array();
5543
-        if( isset( $this->components )) {
5544
-          foreach( $this->components as $cix => $component ) {
5545
-            if( empty( $component )) continue;
5546
-            unset( $component->propix );
5543
+        if (isset($this->components)) {
5544
+          foreach ($this->components as $cix => $component) {
5545
+            if (empty($component)) continue;
5546
+            unset($component->propix);
5547 5547
             $info[$cix]['ordno'] = $cix + 1;
5548 5548
             $info[$cix]['type']  = $component->objName;
5549
-            $info[$cix]['uid']   = $component->getProperty( 'uid' );
5550
-            $info[$cix]['props'] = $component->getConfig( 'propinfo' );
5551
-            $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
5552
-            unset( $component->propix );
5549
+            $info[$cix]['uid']   = $component->getProperty('uid');
5550
+            $info[$cix]['props'] = $component->getConfig('propinfo');
5551
+            $info[$cix]['sub']   = $component->getConfig('compsinfo');
5552
+            unset($component->propix);
5553 5553
           }
5554 5554
         }
5555 5555
         return $info;
@@ -5567,58 +5567,58 @@  discard block
 block discarded – undo
5567 5567
         break;
5568 5568
       case 'PROPINFO':
5569 5569
         $output = array();
5570
-        if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5571
-          if( empty( $this->uid['value'] )) $this->_makeuid();
5570
+        if (!in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) {
5571
+          if (empty($this->uid['value'])) $this->_makeuid();
5572 5572
                                               $output['UID']              = 1;
5573 5573
         }
5574
-        if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5575
-        if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
5576
-        if( !empty( $this->description ))     $output['DESCRIPTION']      = count( $this->description );
5577
-        if( !empty( $this->dtstart ))         $output['DTSTART']          = 1;
5578
-        if( !empty( $this->dtend ))           $output['DTEND']            = 1;
5579
-        if( !empty( $this->due ))             $output['DUE']              = 1;
5580
-        if( !empty( $this->duration ))        $output['DURATION']         = 1;
5581
-        if( !empty( $this->rrule ))           $output['RRULE']            = count( $this->rrule );
5582
-        if( !empty( $this->rdate ))           $output['RDATE']            = count( $this->rdate );
5583
-        if( !empty( $this->exdate ))          $output['EXDATE']           = count( $this->exdate );
5584
-        if( !empty( $this->exrule ))          $output['EXRULE']           = count( $this->exrule );
5585
-        if( !empty( $this->action ))          $output['ACTION']           = 1;
5586
-        if( !empty( $this->attach ))          $output['ATTACH']           = count( $this->attach );
5587
-        if( !empty( $this->attendee ))        $output['ATTENDEE']         = count( $this->attendee );
5588
-        if( !empty( $this->categories ))      $output['CATEGORIES']       = count( $this->categories );
5589
-        if( !empty( $this->class ))           $output['CLASS']            = 1;
5590
-        if( !empty( $this->comment ))         $output['COMMENT']          = count( $this->comment );
5591
-        if( !empty( $this->completed ))       $output['COMPLETED']        = 1;
5592
-        if( !empty( $this->contact ))         $output['CONTACT']          = count( $this->contact );
5593
-        if( !empty( $this->created ))         $output['CREATED']          = 1;
5594
-        if( !empty( $this->freebusy ))        $output['FREEBUSY']         = count( $this->freebusy );
5595
-        if( !empty( $this->geo ))             $output['GEO']              = 1;
5596
-        if( !empty( $this->lastmodified ))    $output['LAST-MODIFIED']    = 1;
5597
-        if( !empty( $this->location ))        $output['LOCATION']         = 1;
5598
-        if( !empty( $this->organizer ))       $output['ORGANIZER']        = 1;
5599
-        if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1;
5600
-        if( !empty( $this->priority ))        $output['PRIORITY']         = 1;
5601
-        if( !empty( $this->recurrenceid ))    $output['RECURRENCE-ID']    = 1;
5602
-        if( !empty( $this->relatedto ))       $output['RELATED-TO']       = count( $this->relatedto );
5603
-        if( !empty( $this->repeat ))          $output['REPEAT']           = 1;
5604
-        if( !empty( $this->requeststatus ))   $output['REQUEST-STATUS']   = count( $this->requeststatus );
5605
-        if( !empty( $this->resources ))       $output['RESOURCES']        = count( $this->resources );
5606
-        if( !empty( $this->sequence ))        $output['SEQUENCE']         = 1;
5607
-        if( !empty( $this->status ))          $output['STATUS']           = 1;
5608
-        if( !empty( $this->transp ))          $output['TRANSP']           = 1;
5609
-        if( !empty( $this->trigger ))         $output['TRIGGER']          = 1;
5610
-        if( !empty( $this->tzid ))            $output['TZID']             = 1;
5611
-        if( !empty( $this->tzname ))          $output['TZNAME']           = count( $this->tzname );
5612
-        if( !empty( $this->tzoffsetfrom ))    $output['TZOFFSETTFROM']    = 1;
5613
-        if( !empty( $this->tzoffsetto ))      $output['TZOFFSETTO']       = 1;
5614
-        if( !empty( $this->tzurl ))           $output['TZURL']            = 1;
5615
-        if( !empty( $this->url ))             $output['URL']              = 1;
5616
-        if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
5574
+        if (!empty($this->dtstamp))         $output['DTSTAMP']          = 1;
5575
+        if (!empty($this->summary))         $output['SUMMARY']          = 1;
5576
+        if (!empty($this->description))     $output['DESCRIPTION']      = count($this->description);
5577
+        if (!empty($this->dtstart))         $output['DTSTART']          = 1;
5578
+        if (!empty($this->dtend))           $output['DTEND']            = 1;
5579
+        if (!empty($this->due))             $output['DUE']              = 1;
5580
+        if (!empty($this->duration))        $output['DURATION']         = 1;
5581
+        if (!empty($this->rrule))           $output['RRULE']            = count($this->rrule);
5582
+        if (!empty($this->rdate))           $output['RDATE']            = count($this->rdate);
5583
+        if (!empty($this->exdate))          $output['EXDATE']           = count($this->exdate);
5584
+        if (!empty($this->exrule))          $output['EXRULE']           = count($this->exrule);
5585
+        if (!empty($this->action))          $output['ACTION']           = 1;
5586
+        if (!empty($this->attach))          $output['ATTACH']           = count($this->attach);
5587
+        if (!empty($this->attendee))        $output['ATTENDEE']         = count($this->attendee);
5588
+        if (!empty($this->categories))      $output['CATEGORIES']       = count($this->categories);
5589
+        if (!empty($this->class))           $output['CLASS']            = 1;
5590
+        if (!empty($this->comment))         $output['COMMENT']          = count($this->comment);
5591
+        if (!empty($this->completed))       $output['COMPLETED']        = 1;
5592
+        if (!empty($this->contact))         $output['CONTACT']          = count($this->contact);
5593
+        if (!empty($this->created))         $output['CREATED']          = 1;
5594
+        if (!empty($this->freebusy))        $output['FREEBUSY']         = count($this->freebusy);
5595
+        if (!empty($this->geo))             $output['GEO']              = 1;
5596
+        if (!empty($this->lastmodified))    $output['LAST-MODIFIED']    = 1;
5597
+        if (!empty($this->location))        $output['LOCATION']         = 1;
5598
+        if (!empty($this->organizer))       $output['ORGANIZER']        = 1;
5599
+        if (!empty($this->percentcomplete)) $output['PERCENT-COMPLETE'] = 1;
5600
+        if (!empty($this->priority))        $output['PRIORITY']         = 1;
5601
+        if (!empty($this->recurrenceid))    $output['RECURRENCE-ID']    = 1;
5602
+        if (!empty($this->relatedto))       $output['RELATED-TO']       = count($this->relatedto);
5603
+        if (!empty($this->repeat))          $output['REPEAT']           = 1;
5604
+        if (!empty($this->requeststatus))   $output['REQUEST-STATUS']   = count($this->requeststatus);
5605
+        if (!empty($this->resources))       $output['RESOURCES']        = count($this->resources);
5606
+        if (!empty($this->sequence))        $output['SEQUENCE']         = 1;
5607
+        if (!empty($this->status))          $output['STATUS']           = 1;
5608
+        if (!empty($this->transp))          $output['TRANSP']           = 1;
5609
+        if (!empty($this->trigger))         $output['TRIGGER']          = 1;
5610
+        if (!empty($this->tzid))            $output['TZID']             = 1;
5611
+        if (!empty($this->tzname))          $output['TZNAME']           = count($this->tzname);
5612
+        if (!empty($this->tzoffsetfrom))    $output['TZOFFSETTFROM']    = 1;
5613
+        if (!empty($this->tzoffsetto))      $output['TZOFFSETTO']       = 1;
5614
+        if (!empty($this->tzurl))           $output['TZURL']            = 1;
5615
+        if (!empty($this->url))             $output['URL']              = 1;
5616
+        if (!empty($this->xprop))           $output['X-PROP']           = count($this->xprop);
5617 5617
         return $output;
5618 5618
         break;
5619 5619
       case 'UNIQUE_ID':
5620
-        if( empty( $this->unique_id ))
5621
-          $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
5620
+        if (empty($this->unique_id))
5621
+          $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost';
5622 5622
         return $this->unique_id;
5623 5623
         break;
5624 5624
     }
@@ -5632,47 +5632,47 @@  discard block
 block discarded – undo
5632 5632
  * @param string $value
5633 5633
  * @return void
5634 5634
  */
5635
-  function setConfig( $config, $value ) {
5635
+  function setConfig($config, $value) {
5636 5636
     $res = FALSE;
5637
-    switch( strtoupper( $config )) {
5637
+    switch (strtoupper($config)) {
5638 5638
       case 'ALLOWEMPTY':
5639 5639
         $this->allowEmpty = $value;
5640
-        $subcfg = array( 'ALLOWEMPTY' => $value );
5640
+        $subcfg = array('ALLOWEMPTY' => $value);
5641 5641
         $res    = TRUE;
5642 5642
         break;
5643 5643
       case 'FORMAT':
5644
-        $value  = trim( $value );
5644
+        $value  = trim($value);
5645 5645
         $this->format = $value;
5646 5646
         $this->_createFormat();
5647
-        $subcfg = array( 'FORMAT' => $value );
5647
+        $subcfg = array('FORMAT' => $value);
5648 5648
         $res    = TRUE;
5649 5649
         break;
5650 5650
       case 'LANGUAGE':
5651 5651
          // set language for calendar component as defined in [RFC 1766]
5652
-        $value  = trim( $value );
5652
+        $value  = trim($value);
5653 5653
         $this->language = $value;
5654
-        $subcfg = array( 'LANGUAGE' => $value );
5654
+        $subcfg = array('LANGUAGE' => $value);
5655 5655
         $res    = TRUE;
5656 5656
         break;
5657 5657
       case 'NL':
5658 5658
       case 'NEWLINECHAR':
5659 5659
         $this->nl = $value;
5660
-        $subcfg = array( 'NL' => $value );
5660
+        $subcfg = array('NL' => $value);
5661 5661
         $res    = TRUE;
5662 5662
         break;
5663 5663
       case 'UNIQUE_ID':
5664
-        $value  = trim( $value );
5664
+        $value  = trim($value);
5665 5665
         $this->unique_id = $value;
5666
-        $subcfg = array( 'UNIQUE_ID' => $value );
5666
+        $subcfg = array('UNIQUE_ID' => $value);
5667 5667
         $res    = TRUE;
5668 5668
         break;
5669 5669
     }
5670
-    if( !$res ) return FALSE;
5671
-    if( isset( $subcfg ) && !empty( $this->components )) {
5672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
5673
-        foreach( $this->components as $cix => $component ) {
5674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
5675
-          if( !$res )
5670
+    if (!$res) return FALSE;
5671
+    if (isset($subcfg) && !empty($this->components)) {
5672
+      foreach ($subcfg as $cfgkey => $cfgvalue) {
5673
+        foreach ($this->components as $cix => $component) {
5674
+          $res = $component->setConfig($cfgkey, $cfgvalue);
5675
+          if (!$res)
5676 5676
             break 2;
5677 5677
           $this->components[$cix] = $component; // PHP4 compliant
5678 5678
         }
@@ -5690,248 +5690,248 @@  discard block
 block discarded – undo
5690 5690
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5691 5691
  * @return bool, if successfull delete TRUE
5692 5692
  */
5693
-  function deleteProperty( $propName, $propix=FALSE ) {
5694
-    if( $this->_notExistProp( $propName )) return FALSE;
5695
-    $propName = strtoupper( $propName );
5696
-    if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5697
-                                    'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5698
-      if( !$propix )
5699
-        $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
5693
+  function deleteProperty($propName, $propix = FALSE) {
5694
+    if ($this->_notExistProp($propName)) return FALSE;
5695
+    $propName = strtoupper($propName);
5696
+    if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE',
5697
+                                    'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) {
5698
+      if (!$propix)
5699
+        $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1;
5700 5700
       $this->propdelix[$propName] = --$propix;
5701 5701
     }
5702 5702
     $return = FALSE;
5703
-    switch( $propName ) {
5703
+    switch ($propName) {
5704 5704
       case 'ACTION':
5705
-        if( !empty( $this->action )) {
5705
+        if (!empty($this->action)) {
5706 5706
           $this->action = '';
5707 5707
           $return = TRUE;
5708 5708
         }
5709 5709
         break;
5710 5710
       case 'ATTACH':
5711
-        return $this->deletePropertyM( $this->attach, $propix );
5711
+        return $this->deletePropertyM($this->attach, $propix);
5712 5712
         break;
5713 5713
       case 'ATTENDEE':
5714
-        return $this->deletePropertyM( $this->attendee, $propix );
5714
+        return $this->deletePropertyM($this->attendee, $propix);
5715 5715
         break;
5716 5716
       case 'CATEGORIES':
5717
-        return $this->deletePropertyM( $this->categories, $propix );
5717
+        return $this->deletePropertyM($this->categories, $propix);
5718 5718
         break;
5719 5719
       case 'CLASS':
5720
-        if( !empty( $this->class )) {
5720
+        if (!empty($this->class)) {
5721 5721
           $this->class = '';
5722 5722
           $return = TRUE;
5723 5723
         }
5724 5724
         break;
5725 5725
       case 'COMMENT':
5726
-        return $this->deletePropertyM( $this->comment, $propix );
5726
+        return $this->deletePropertyM($this->comment, $propix);
5727 5727
         break;
5728 5728
       case 'COMPLETED':
5729
-        if( !empty( $this->completed )) {
5729
+        if (!empty($this->completed)) {
5730 5730
           $this->completed = '';
5731 5731
           $return = TRUE;
5732 5732
         }
5733 5733
         break;
5734 5734
       case 'CONTACT':
5735
-        return $this->deletePropertyM( $this->contact, $propix );
5735
+        return $this->deletePropertyM($this->contact, $propix);
5736 5736
         break;
5737 5737
       case 'CREATED':
5738
-        if( !empty( $this->created )) {
5738
+        if (!empty($this->created)) {
5739 5739
           $this->created = '';
5740 5740
           $return = TRUE;
5741 5741
         }
5742 5742
         break;
5743 5743
       case 'DESCRIPTION':
5744
-        return $this->deletePropertyM( $this->description, $propix );
5744
+        return $this->deletePropertyM($this->description, $propix);
5745 5745
         break;
5746 5746
       case 'DTEND':
5747
-        if( !empty( $this->dtend )) {
5747
+        if (!empty($this->dtend)) {
5748 5748
           $this->dtend = '';
5749 5749
           $return = TRUE;
5750 5750
         }
5751 5751
         break;
5752 5752
       case 'DTSTAMP':
5753
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5753
+        if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight')))
5754 5754
           return FALSE;
5755
-        if( !empty( $this->dtstamp )) {
5755
+        if (!empty($this->dtstamp)) {
5756 5756
           $this->dtstamp = '';
5757 5757
           $return = TRUE;
5758 5758
         }
5759 5759
         break;
5760 5760
       case 'DTSTART':
5761
-        if( !empty( $this->dtstart )) {
5761
+        if (!empty($this->dtstart)) {
5762 5762
           $this->dtstart = '';
5763 5763
           $return = TRUE;
5764 5764
         }
5765 5765
         break;
5766 5766
       case 'DUE':
5767
-        if( !empty( $this->due )) {
5767
+        if (!empty($this->due)) {
5768 5768
           $this->due = '';
5769 5769
           $return = TRUE;
5770 5770
         }
5771 5771
         break;
5772 5772
       case 'DURATION':
5773
-        if( !empty( $this->duration )) {
5773
+        if (!empty($this->duration)) {
5774 5774
           $this->duration = '';
5775 5775
           $return = TRUE;
5776 5776
         }
5777 5777
         break;
5778 5778
       case 'EXDATE':
5779
-        return $this->deletePropertyM( $this->exdate, $propix );
5779
+        return $this->deletePropertyM($this->exdate, $propix);
5780 5780
         break;
5781 5781
       case 'EXRULE':
5782
-        return $this->deletePropertyM( $this->exrule, $propix );
5782
+        return $this->deletePropertyM($this->exrule, $propix);
5783 5783
         break;
5784 5784
       case 'FREEBUSY':
5785
-        return $this->deletePropertyM( $this->freebusy, $propix );
5785
+        return $this->deletePropertyM($this->freebusy, $propix);
5786 5786
         break;
5787 5787
       case 'GEO':
5788
-        if( !empty( $this->geo )) {
5788
+        if (!empty($this->geo)) {
5789 5789
           $this->geo = '';
5790 5790
           $return = TRUE;
5791 5791
         }
5792 5792
         break;
5793 5793
       case 'LAST-MODIFIED':
5794
-        if( !empty( $this->lastmodified )) {
5794
+        if (!empty($this->lastmodified)) {
5795 5795
           $this->lastmodified = '';
5796 5796
           $return = TRUE;
5797 5797
         }
5798 5798
         break;
5799 5799
       case 'LOCATION':
5800
-        if( !empty( $this->location )) {
5800
+        if (!empty($this->location)) {
5801 5801
           $this->location = '';
5802 5802
           $return = TRUE;
5803 5803
         }
5804 5804
         break;
5805 5805
       case 'ORGANIZER':
5806
-        if( !empty( $this->organizer )) {
5806
+        if (!empty($this->organizer)) {
5807 5807
           $this->organizer = '';
5808 5808
           $return = TRUE;
5809 5809
         }
5810 5810
         break;
5811 5811
       case 'PERCENT-COMPLETE':
5812
-        if( !empty( $this->percentcomplete )) {
5812
+        if (!empty($this->percentcomplete)) {
5813 5813
           $this->percentcomplete = '';
5814 5814
           $return = TRUE;
5815 5815
         }
5816 5816
         break;
5817 5817
       case 'PRIORITY':
5818
-        if( !empty( $this->priority )) {
5818
+        if (!empty($this->priority)) {
5819 5819
           $this->priority = '';
5820 5820
           $return = TRUE;
5821 5821
         }
5822 5822
         break;
5823 5823
       case 'RDATE':
5824
-        return $this->deletePropertyM( $this->rdate, $propix );
5824
+        return $this->deletePropertyM($this->rdate, $propix);
5825 5825
         break;
5826 5826
       case 'RECURRENCE-ID':
5827
-        if( !empty( $this->recurrenceid )) {
5827
+        if (!empty($this->recurrenceid)) {
5828 5828
           $this->recurrenceid = '';
5829 5829
           $return = TRUE;
5830 5830
         }
5831 5831
         break;
5832 5832
       case 'RELATED-TO':
5833
-        return $this->deletePropertyM( $this->relatedto, $propix );
5833
+        return $this->deletePropertyM($this->relatedto, $propix);
5834 5834
         break;
5835 5835
       case 'REPEAT':
5836
-        if( !empty( $this->repeat )) {
5836
+        if (!empty($this->repeat)) {
5837 5837
           $this->repeat = '';
5838 5838
           $return = TRUE;
5839 5839
         }
5840 5840
         break;
5841 5841
       case 'REQUEST-STATUS':
5842
-        return $this->deletePropertyM( $this->requeststatus, $propix );
5842
+        return $this->deletePropertyM($this->requeststatus, $propix);
5843 5843
         break;
5844 5844
       case 'RESOURCES':
5845
-        return $this->deletePropertyM( $this->resources, $propix );
5845
+        return $this->deletePropertyM($this->resources, $propix);
5846 5846
         break;
5847 5847
       case 'RRULE':
5848
-        return $this->deletePropertyM( $this->rrule, $propix );
5848
+        return $this->deletePropertyM($this->rrule, $propix);
5849 5849
         break;
5850 5850
       case 'SEQUENCE':
5851
-        if( !empty( $this->sequence )) {
5851
+        if (!empty($this->sequence)) {
5852 5852
           $this->sequence = '';
5853 5853
           $return = TRUE;
5854 5854
         }
5855 5855
         break;
5856 5856
       case 'STATUS':
5857
-        if( !empty( $this->status )) {
5857
+        if (!empty($this->status)) {
5858 5858
           $this->status = '';
5859 5859
           $return = TRUE;
5860 5860
         }
5861 5861
         break;
5862 5862
       case 'SUMMARY':
5863
-        if( !empty( $this->summary )) {
5863
+        if (!empty($this->summary)) {
5864 5864
           $this->summary = '';
5865 5865
           $return = TRUE;
5866 5866
         }
5867 5867
         break;
5868 5868
       case 'TRANSP':
5869
-        if( !empty( $this->transp )) {
5869
+        if (!empty($this->transp)) {
5870 5870
           $this->transp = '';
5871 5871
           $return = TRUE;
5872 5872
         }
5873 5873
         break;
5874 5874
       case 'TRIGGER':
5875
-        if( !empty( $this->trigger )) {
5875
+        if (!empty($this->trigger)) {
5876 5876
           $this->trigger = '';
5877 5877
           $return = TRUE;
5878 5878
         }
5879 5879
         break;
5880 5880
       case 'TZID':
5881
-        if( !empty( $this->tzid )) {
5881
+        if (!empty($this->tzid)) {
5882 5882
           $this->tzid = '';
5883 5883
           $return = TRUE;
5884 5884
         }
5885 5885
         break;
5886 5886
       case 'TZNAME':
5887
-        return $this->deletePropertyM( $this->tzname, $propix );
5887
+        return $this->deletePropertyM($this->tzname, $propix);
5888 5888
         break;
5889 5889
       case 'TZOFFSETFROM':
5890
-        if( !empty( $this->tzoffsetfrom )) {
5890
+        if (!empty($this->tzoffsetfrom)) {
5891 5891
           $this->tzoffsetfrom = '';
5892 5892
           $return = TRUE;
5893 5893
         }
5894 5894
         break;
5895 5895
       case 'TZOFFSETTO':
5896
-        if( !empty( $this->tzoffsetto )) {
5896
+        if (!empty($this->tzoffsetto)) {
5897 5897
           $this->tzoffsetto = '';
5898 5898
           $return = TRUE;
5899 5899
         }
5900 5900
         break;
5901 5901
       case 'TZURL':
5902
-        if( !empty( $this->tzurl )) {
5902
+        if (!empty($this->tzurl)) {
5903 5903
           $this->tzurl = '';
5904 5904
           $return = TRUE;
5905 5905
         }
5906 5906
         break;
5907 5907
       case 'UID':
5908
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5908
+        if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight')))
5909 5909
           return FALSE;
5910
-        if( !empty( $this->uid )) {
5910
+        if (!empty($this->uid)) {
5911 5911
           $this->uid = '';
5912 5912
           $return = TRUE;
5913 5913
         }
5914 5914
         break;
5915 5915
       case 'URL':
5916
-        if( !empty( $this->url )) {
5916
+        if (!empty($this->url)) {
5917 5917
           $this->url = '';
5918 5918
           $return = TRUE;
5919 5919
         }
5920 5920
         break;
5921 5921
       default:
5922 5922
         $reduced = '';
5923
-        if( $propName != 'X-PROP' ) {
5924
-          if( !isset( $this->xprop[$propName] )) return FALSE;
5925
-          foreach( $this->xprop as $k => $a ) {
5926
-            if(( $k != $propName ) && !empty( $a ))
5923
+        if ($propName != 'X-PROP') {
5924
+          if (!isset($this->xprop[$propName])) return FALSE;
5925
+          foreach ($this->xprop as $k => $a) {
5926
+            if (($k != $propName) && !empty($a))
5927 5927
               $reduced[$k] = $a;
5928 5928
           }
5929 5929
         }
5930 5930
         else {
5931
-          if( count( $this->xprop ) <= $propix )  return FALSE;
5931
+          if (count($this->xprop) <= $propix)  return FALSE;
5932 5932
           $xpropno = 0;
5933
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5934
-            if( $propix != $xpropno )
5933
+          foreach ($this->xprop as $xpropkey => $xpropvalue) {
5934
+            if ($propix != $xpropno)
5935 5935
               $reduced[$xpropkey] = $xpropvalue;
5936 5936
             $xpropno++;
5937 5937
           }
@@ -5951,11 +5951,11 @@  discard block
 block discarded – undo
5951 5951
  * @param int @propix, default 0
5952 5952
  * @return bool TRUE
5953 5953
  */
5954
-  function deletePropertyM( & $multiprop, $propix=0 ) {
5955
-    if( !isset( $multiprop[$propix])) return FALSE;
5956
-    unset( $multiprop[$propix] );
5957
-    if( empty( $multiprop )) $multiprop = '';
5958
-    return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5954
+  function deletePropertyM(& $multiprop, $propix = 0) {
5955
+    if (!isset($multiprop[$propix])) return FALSE;
5956
+    unset($multiprop[$propix]);
5957
+    if (empty($multiprop)) $multiprop = '';
5958
+    return (isset($this->multiprop[$propix])) ? FALSE : TRUE;
5959 5959
   }
5960 5960
 /**
5961 5961
  * get component property value/params
@@ -5970,183 +5970,183 @@  discard block
 block discarded – undo
5970 5970
  * @param bool $specform=FALSE
5971 5971
  * @return mixed
5972 5972
  */
5973
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5974
-    if( $this->_notExistProp( $propName )) return FALSE;
5975
-    $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
5976
-    if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5977
-                                    'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5978
-      if( !$propix )
5979
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
5973
+  function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) {
5974
+    if ($this->_notExistProp($propName)) return FALSE;
5975
+    $propName = ($propName) ? strtoupper($propName) : 'X-PROP';
5976
+    if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE',
5977
+                                    'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) {
5978
+      if (!$propix)
5979
+        $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1;
5980 5980
       $this->propix[$propName] = --$propix;
5981 5981
     }
5982
-    switch( $propName ) {
5982
+    switch ($propName) {
5983 5983
       case 'ACTION':
5984
-        if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
5984
+        if (!empty($this->action['value'])) return ($inclParam) ? $this->action : $this->action['value'];
5985 5985
         break;
5986 5986
       case 'ATTACH':
5987
-        if( !isset( $this->attach[$propix] )) return FALSE;
5988
-        return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5987
+        if (!isset($this->attach[$propix])) return FALSE;
5988
+        return ($inclParam) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5989 5989
         break;
5990 5990
       case 'ATTENDEE':
5991
-        if( !isset( $this->attendee[$propix] )) return FALSE;
5992
-        return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5991
+        if (!isset($this->attendee[$propix])) return FALSE;
5992
+        return ($inclParam) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5993 5993
         break;
5994 5994
       case 'CATEGORIES':
5995
-        if( !isset( $this->categories[$propix] )) return FALSE;
5996
-        return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5995
+        if (!isset($this->categories[$propix])) return FALSE;
5996
+        return ($inclParam) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5997 5997
         break;
5998 5998
       case 'CLASS':
5999
-        if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
5999
+        if (!empty($this->class['value'])) return ($inclParam) ? $this->class : $this->class['value'];
6000 6000
         break;
6001 6001
       case 'COMMENT':
6002
-        if( !isset( $this->comment[$propix] )) return FALSE;
6003
-        return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6002
+        if (!isset($this->comment[$propix])) return FALSE;
6003
+        return ($inclParam) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6004 6004
         break;
6005 6005
       case 'COMPLETED':
6006
-        if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6006
+        if (!empty($this->completed['value'])) return ($inclParam) ? $this->completed : $this->completed['value'];
6007 6007
         break;
6008 6008
       case 'CONTACT':
6009
-        if( !isset( $this->contact[$propix] )) return FALSE;
6010
-        return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6009
+        if (!isset($this->contact[$propix])) return FALSE;
6010
+        return ($inclParam) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6011 6011
         break;
6012 6012
       case 'CREATED':
6013
-        if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6013
+        if (!empty($this->created['value'])) return ($inclParam) ? $this->created : $this->created['value'];
6014 6014
         break;
6015 6015
       case 'DESCRIPTION':
6016
-        if( !isset( $this->description[$propix] )) return FALSE;
6017
-        return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6016
+        if (!isset($this->description[$propix])) return FALSE;
6017
+        return ($inclParam) ? $this->description[$propix] : $this->description[$propix]['value'];
6018 6018
         break;
6019 6019
       case 'DTEND':
6020
-        if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6020
+        if (!empty($this->dtend['value'])) return ($inclParam) ? $this->dtend : $this->dtend['value'];
6021 6021
         break;
6022 6022
       case 'DTSTAMP':
6023
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6023
+        if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight')))
6024 6024
           return;
6025
-        if( !isset( $this->dtstamp['value'] ))
6025
+        if (!isset($this->dtstamp['value']))
6026 6026
           $this->_makeDtstamp();
6027
-        return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6027
+        return ($inclParam) ? $this->dtstamp : $this->dtstamp['value'];
6028 6028
         break;
6029 6029
       case 'DTSTART':
6030
-        if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6030
+        if (!empty($this->dtstart['value'])) return ($inclParam) ? $this->dtstart : $this->dtstart['value'];
6031 6031
         break;
6032 6032
       case 'DUE':
6033
-        if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6033
+        if (!empty($this->due['value'])) return ($inclParam) ? $this->due : $this->due['value'];
6034 6034
         break;
6035 6035
       case 'DURATION':
6036
-        if( !isset( $this->duration['value'] )) return FALSE;
6037
-        $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6038
-        return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6036
+        if (!isset($this->duration['value'])) return FALSE;
6037
+        $value = ($specform) ? $this->duration2date() : $this->duration['value'];
6038
+        return ($inclParam) ? array('value' => $value, 'params' =>  $this->duration['params']) : $value;
6039 6039
         break;
6040 6040
       case 'EXDATE':
6041
-        if( !isset( $this->exdate[$propix] )) return FALSE;
6042
-        return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6041
+        if (!isset($this->exdate[$propix])) return FALSE;
6042
+        return ($inclParam) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6043 6043
         break;
6044 6044
       case 'EXRULE':
6045
-        if( !isset( $this->exrule[$propix] )) return FALSE;
6046
-        return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6045
+        if (!isset($this->exrule[$propix])) return FALSE;
6046
+        return ($inclParam) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6047 6047
         break;
6048 6048
       case 'FREEBUSY':
6049
-        if( !isset( $this->freebusy[$propix] )) return FALSE;
6050
-        return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6049
+        if (!isset($this->freebusy[$propix])) return FALSE;
6050
+        return ($inclParam) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6051 6051
         break;
6052 6052
       case 'GEO':
6053
-        if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6053
+        if (!empty($this->geo['value'])) return ($inclParam) ? $this->geo : $this->geo['value'];
6054 6054
         break;
6055 6055
       case 'LAST-MODIFIED':
6056
-        if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6056
+        if (!empty($this->lastmodified['value'])) return ($inclParam) ? $this->lastmodified : $this->lastmodified['value'];
6057 6057
         break;
6058 6058
       case 'LOCATION':
6059
-        if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6059
+        if (!empty($this->location['value'])) return ($inclParam) ? $this->location : $this->location['value'];
6060 6060
         break;
6061 6061
       case 'ORGANIZER':
6062
-        if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6062
+        if (!empty($this->organizer['value'])) return ($inclParam) ? $this->organizer : $this->organizer['value'];
6063 6063
         break;
6064 6064
       case 'PERCENT-COMPLETE':
6065
-        if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6065
+        if (!empty($this->percentcomplete['value'])) return ($inclParam) ? $this->percentcomplete : $this->percentcomplete['value'];
6066 6066
         break;
6067 6067
       case 'PRIORITY':
6068
-        if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6068
+        if (!empty($this->priority['value'])) return ($inclParam) ? $this->priority : $this->priority['value'];
6069 6069
         break;
6070 6070
       case 'RDATE':
6071
-        if( !isset( $this->rdate[$propix] )) return FALSE;
6072
-        return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6071
+        if (!isset($this->rdate[$propix])) return FALSE;
6072
+        return ($inclParam) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6073 6073
         break;
6074 6074
       case 'RECURRENCE-ID':
6075
-        if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6075
+        if (!empty($this->recurrenceid['value'])) return ($inclParam) ? $this->recurrenceid : $this->recurrenceid['value'];
6076 6076
         break;
6077 6077
       case 'RELATED-TO':
6078
-        if( !isset( $this->relatedto[$propix] )) return FALSE;
6079
-        return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6078
+        if (!isset($this->relatedto[$propix])) return FALSE;
6079
+        return ($inclParam) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6080 6080
         break;
6081 6081
       case 'REPEAT':
6082
-        if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6082
+        if (!empty($this->repeat['value'])) return ($inclParam) ? $this->repeat : $this->repeat['value'];
6083 6083
         break;
6084 6084
       case 'REQUEST-STATUS':
6085
-        if( !isset( $this->requeststatus[$propix] )) return FALSE;
6086
-        return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6085
+        if (!isset($this->requeststatus[$propix])) return FALSE;
6086
+        return ($inclParam) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6087 6087
         break;
6088 6088
       case 'RESOURCES':
6089
-        if( !isset( $this->resources[$propix] )) return FALSE;
6090
-        return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6089
+        if (!isset($this->resources[$propix])) return FALSE;
6090
+        return ($inclParam) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6091 6091
         break;
6092 6092
       case 'RRULE':
6093
-        if( !isset( $this->rrule[$propix] )) return FALSE;
6094
-        return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6093
+        if (!isset($this->rrule[$propix])) return FALSE;
6094
+        return ($inclParam) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6095 6095
         break;
6096 6096
       case 'SEQUENCE':
6097
-        if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6097
+        if (!empty($this->sequence['value'])) return ($inclParam) ? $this->sequence : $this->sequence['value'];
6098 6098
         break;
6099 6099
       case 'STATUS':
6100
-        if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6100
+        if (!empty($this->status['value'])) return ($inclParam) ? $this->status : $this->status['value'];
6101 6101
         break;
6102 6102
       case 'SUMMARY':
6103
-        if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6103
+        if (!empty($this->summary['value'])) return ($inclParam) ? $this->summary : $this->summary['value'];
6104 6104
         break;
6105 6105
       case 'TRANSP':
6106
-        if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6106
+        if (!empty($this->transp['value'])) return ($inclParam) ? $this->transp : $this->transp['value'];
6107 6107
         break;
6108 6108
       case 'TRIGGER':
6109
-        if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6109
+        if (!empty($this->trigger['value'])) return ($inclParam) ? $this->trigger : $this->trigger['value'];
6110 6110
         break;
6111 6111
       case 'TZID':
6112
-        if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6112
+        if (!empty($this->tzid['value'])) return ($inclParam) ? $this->tzid : $this->tzid['value'];
6113 6113
         break;
6114 6114
       case 'TZNAME':
6115
-        if( !isset( $this->tzname[$propix] )) return FALSE;
6116
-        return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6115
+        if (!isset($this->tzname[$propix])) return FALSE;
6116
+        return ($inclParam) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6117 6117
         break;
6118 6118
       case 'TZOFFSETFROM':
6119
-        if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6119
+        if (!empty($this->tzoffsetfrom['value'])) return ($inclParam) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6120 6120
         break;
6121 6121
       case 'TZOFFSETTO':
6122
-        if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6122
+        if (!empty($this->tzoffsetto['value'])) return ($inclParam) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6123 6123
         break;
6124 6124
       case 'TZURL':
6125
-        if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6125
+        if (!empty($this->tzurl['value'])) return ($inclParam) ? $this->tzurl : $this->tzurl['value'];
6126 6126
         break;
6127 6127
       case 'UID':
6128
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6128
+        if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight')))
6129 6129
           return FALSE;
6130
-        if( empty( $this->uid['value'] ))
6130
+        if (empty($this->uid['value']))
6131 6131
           $this->_makeuid();
6132
-        return ( $inclParam ) ? $this->uid : $this->uid['value'];
6132
+        return ($inclParam) ? $this->uid : $this->uid['value'];
6133 6133
         break;
6134 6134
       case 'URL':
6135
-        if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
6135
+        if (!empty($this->url['value'])) return ($inclParam) ? $this->url : $this->url['value'];
6136 6136
         break;
6137 6137
       default:
6138
-        if( $propName != 'X-PROP' ) {
6139
-          if( !isset( $this->xprop[$propName] )) return FALSE;
6140
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6141
-                                : array( $propName, $this->xprop[$propName]['value'] );
6138
+        if ($propName != 'X-PROP') {
6139
+          if (!isset($this->xprop[$propName])) return FALSE;
6140
+          return ($inclParam) ? array($propName, $this->xprop[$propName])
6141
+                                : array($propName, $this->xprop[$propName]['value']);
6142 6142
         }
6143 6143
         else {
6144
-          if( empty( $this->xprop )) return FALSE;
6144
+          if (empty($this->xprop)) return FALSE;
6145 6145
           $xpropno = 0;
6146
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6147
-            if( $propix == $xpropno )
6148
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6149
-                                    : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6146
+          foreach ($this->xprop as $xpropkey => $xpropvalue) {
6147
+            if ($propix == $xpropno)
6148
+              return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey])
6149
+                                    : array($xpropkey, $this->xprop[$xpropkey]['value']);
6150 6150
             else
6151 6151
               $xpropno++;
6152 6152
           }
@@ -6167,105 +6167,105 @@  discard block
 block discarded – undo
6167 6167
  */
6168 6168
   function setProperty() {
6169 6169
     $numargs    = func_num_args();
6170
-    if( 1 > $numargs ) return FALSE;
6170
+    if (1 > $numargs) return FALSE;
6171 6171
     $arglist    = func_get_args();
6172
-    if( $this->_notExistProp( $arglist[0] )) return FALSE;
6173
-    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
6172
+    if ($this->_notExistProp($arglist[0])) return FALSE;
6173
+    if (!$this->getConfig('allowEmpty') && (!isset($arglist[1]) || empty($arglist[1])))
6174 6174
       return FALSE;
6175
-    $arglist[0] = strtoupper( $arglist[0] );
6176
-    for( $argix=$numargs; $argix < 12; $argix++ ) {
6177
-      if( !isset( $arglist[$argix] ))
6175
+    $arglist[0] = strtoupper($arglist[0]);
6176
+    for ($argix = $numargs; $argix < 12; $argix++) {
6177
+      if (!isset($arglist[$argix]))
6178 6178
         $arglist[$argix] = null;
6179 6179
     }
6180
-    switch( $arglist[0] ) {
6180
+    switch ($arglist[0]) {
6181 6181
       case 'ACTION':
6182
-        return $this->setAction( $arglist[1], $arglist[2] );
6182
+        return $this->setAction($arglist[1], $arglist[2]);
6183 6183
       case 'ATTACH':
6184
-        return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] );
6184
+        return $this->setAttach($arglist[1], $arglist[2], $arglist[3]);
6185 6185
       case 'ATTENDEE':
6186
-        return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] );
6186
+        return $this->setAttendee($arglist[1], $arglist[2], $arglist[3]);
6187 6187
       case 'CATEGORIES':
6188
-        return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] );
6188
+        return $this->setCategories($arglist[1], $arglist[2], $arglist[3]);
6189 6189
       case 'CLASS':
6190
-        return $this->setClass( $arglist[1], $arglist[2] );
6190
+        return $this->setClass($arglist[1], $arglist[2]);
6191 6191
       case 'COMMENT':
6192
-        return $this->setComment( $arglist[1], $arglist[2], $arglist[3] );
6192
+        return $this->setComment($arglist[1], $arglist[2], $arglist[3]);
6193 6193
       case 'COMPLETED':
6194
-        return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6194
+        return $this->setCompleted($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]);
6195 6195
       case 'CONTACT':
6196
-        return $this->setContact( $arglist[1], $arglist[2], $arglist[3] );
6196
+        return $this->setContact($arglist[1], $arglist[2], $arglist[3]);
6197 6197
       case 'CREATED':
6198
-        return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6198
+        return $this->setCreated($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]);
6199 6199
       case 'DESCRIPTION':
6200
-        return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] );
6200
+        return $this->setDescription($arglist[1], $arglist[2], $arglist[3]);
6201 6201
       case 'DTEND':
6202
-        return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6202
+        return $this->setDtend($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]);
6203 6203
       case 'DTSTAMP':
6204
-        return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6204
+        return $this->setDtstamp($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]);
6205 6205
       case 'DTSTART':
6206
-        return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6206
+        return $this->setDtstart($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]);
6207 6207
       case 'DUE':
6208
-        return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6208
+        return $this->setDue($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]);
6209 6209
       case 'DURATION':
6210
-        return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] );
6210
+        return $this->setDuration($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6]);
6211 6211
       case 'EXDATE':
6212
-        return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] );
6212
+        return $this->setExdate($arglist[1], $arglist[2], $arglist[3]);
6213 6213
       case 'EXRULE':
6214
-        return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] );
6214
+        return $this->setExrule($arglist[1], $arglist[2], $arglist[3]);
6215 6215
       case 'FREEBUSY':
6216
-        return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] );
6216
+        return $this->setFreebusy($arglist[1], $arglist[2], $arglist[3], $arglist[4]);
6217 6217
       case 'GEO':
6218
-        return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] );
6218
+        return $this->setGeo($arglist[1], $arglist[2], $arglist[3]);
6219 6219
       case 'LAST-MODIFIED':
6220
-        return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6220
+        return $this->setLastModified($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]);
6221 6221
       case 'LOCATION':
6222
-        return $this->setLocation( $arglist[1], $arglist[2] );
6222
+        return $this->setLocation($arglist[1], $arglist[2]);
6223 6223
       case 'ORGANIZER':
6224
-        return $this->setOrganizer( $arglist[1], $arglist[2] );
6224
+        return $this->setOrganizer($arglist[1], $arglist[2]);
6225 6225
       case 'PERCENT-COMPLETE':
6226
-        return $this->setPercentComplete( $arglist[1], $arglist[2] );
6226
+        return $this->setPercentComplete($arglist[1], $arglist[2]);
6227 6227
       case 'PRIORITY':
6228
-        return $this->setPriority( $arglist[1], $arglist[2] );
6228
+        return $this->setPriority($arglist[1], $arglist[2]);
6229 6229
       case 'RDATE':
6230
-        return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] );
6230
+        return $this->setRdate($arglist[1], $arglist[2], $arglist[3]);
6231 6231
       case 'RECURRENCE-ID':
6232
-       return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6232
+       return $this->setRecurrenceid($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]);
6233 6233
       case 'RELATED-TO':
6234
-        return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] );
6234
+        return $this->setRelatedTo($arglist[1], $arglist[2], $arglist[3]);
6235 6235
       case 'REPEAT':
6236
-        return $this->setRepeat( $arglist[1], $arglist[2] );
6236
+        return $this->setRepeat($arglist[1], $arglist[2]);
6237 6237
       case 'REQUEST-STATUS':
6238
-        return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] );
6238
+        return $this->setRequestStatus($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5]);
6239 6239
       case 'RESOURCES':
6240
-        return $this->setResources( $arglist[1], $arglist[2], $arglist[3] );
6240
+        return $this->setResources($arglist[1], $arglist[2], $arglist[3]);
6241 6241
       case 'RRULE':
6242
-        return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] );
6242
+        return $this->setRrule($arglist[1], $arglist[2], $arglist[3]);
6243 6243
       case 'SEQUENCE':
6244
-        return $this->setSequence( $arglist[1], $arglist[2] );
6244
+        return $this->setSequence($arglist[1], $arglist[2]);
6245 6245
       case 'STATUS':
6246
-        return $this->setStatus( $arglist[1], $arglist[2] );
6246
+        return $this->setStatus($arglist[1], $arglist[2]);
6247 6247
       case 'SUMMARY':
6248
-        return $this->setSummary( $arglist[1], $arglist[2] );
6248
+        return $this->setSummary($arglist[1], $arglist[2]);
6249 6249
       case 'TRANSP':
6250
-        return $this->setTransp( $arglist[1], $arglist[2] );
6250
+        return $this->setTransp($arglist[1], $arglist[2]);
6251 6251
       case 'TRIGGER':
6252
-        return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] );
6252
+        return $this->setTrigger($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11]);
6253 6253
       case 'TZID':
6254
-        return $this->setTzid( $arglist[1], $arglist[2] );
6254
+        return $this->setTzid($arglist[1], $arglist[2]);
6255 6255
       case 'TZNAME':
6256
-        return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] );
6256
+        return $this->setTzname($arglist[1], $arglist[2], $arglist[3]);
6257 6257
       case 'TZOFFSETFROM':
6258
-        return $this->setTzoffsetfrom( $arglist[1], $arglist[2] );
6258
+        return $this->setTzoffsetfrom($arglist[1], $arglist[2]);
6259 6259
       case 'TZOFFSETTO':
6260
-        return $this->setTzoffsetto( $arglist[1], $arglist[2] );
6260
+        return $this->setTzoffsetto($arglist[1], $arglist[2]);
6261 6261
       case 'TZURL':
6262
-        return $this->setTzurl( $arglist[1], $arglist[2] );
6262
+        return $this->setTzurl($arglist[1], $arglist[2]);
6263 6263
       case 'UID':
6264
-        return $this->setUid( $arglist[1], $arglist[2] );
6264
+        return $this->setUid($arglist[1], $arglist[2]);
6265 6265
       case 'URL':
6266
-        return $this->setUrl( $arglist[1], $arglist[2] );
6266
+        return $this->setUrl($arglist[1], $arglist[2]);
6267 6267
       default:
6268
-        return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
6268
+        return $this->setXprop($arglist[0], $arglist[1], $arglist[2]);
6269 6269
     }
6270 6270
     return FALSE;
6271 6271
   }
@@ -6279,18 +6279,18 @@  discard block
 block discarded – undo
6279 6279
  * @return bool FALSE if error occurs during parsing
6280 6280
  *
6281 6281
  */
6282
-  function parse( $unparsedtext=null ) {
6283
-    if( $unparsedtext ) {
6282
+  function parse($unparsedtext = null) {
6283
+    if ($unparsedtext) {
6284 6284
       $this->unparsed = array();
6285
-      if( is_array( $unparsedtext )) {
6285
+      if (is_array($unparsedtext)) {
6286 6286
         $comp = & $this;
6287
-        foreach ( $unparsedtext as $line ) {
6288
-          if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) {
6289
-            $this->setComponent( $comp );
6290
-            $comp =  & $this;
6287
+        foreach ($unparsedtext as $line) {
6288
+          if ('END:VALARM' == strtoupper(substr($line, 0, 10))) {
6289
+            $this->setComponent($comp);
6290
+            $comp = & $this;
6291 6291
             continue;
6292 6292
           }
6293
-          elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6293
+          elseif ('BEGIN:VALARM' == strtoupper(substr($line, 0, 12))) {
6294 6294
             $comp = new valarm();
6295 6295
             continue;
6296 6296
           }
@@ -6299,215 +6299,215 @@  discard block
 block discarded – undo
6299 6299
         }
6300 6300
       }
6301 6301
       else
6302
-        $this->unparsed = array( trim( $unparsedtext ));
6302
+        $this->unparsed = array(trim($unparsedtext));
6303 6303
     }
6304
-    elseif( !isset( $this->unparsed ))
6304
+    elseif (!isset($this->unparsed))
6305 6305
       $this->unparsed = array();
6306 6306
             /* concatenate property values spread over several lines */
6307 6307
     $lastix    = -1;
6308
-    $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
6308
+    $propnames = array('action', 'attach', 'attendee', 'categories', 'comment', 'completed'
6309 6309
                       , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart'
6310 6310
                       , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo'
6311 6311
                       , 'last-modified', 'location', 'organizer', 'percent-complete'
6312 6312
                       , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat'
6313 6313
                       , 'request-status', 'resources', 'rrule', 'sequence', 'status'
6314 6314
                       , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom'
6315
-                      , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' );
6315
+                      , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-');
6316 6316
     $proprows  = array();
6317
-    foreach( $this->unparsed as $line ) {
6317
+    foreach ($this->unparsed as $line) {
6318 6318
       $newProp = FALSE;
6319
-      foreach ( $propnames as $propname ) {
6320
-        if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
6319
+      foreach ($propnames as $propname) {
6320
+        if ($propname == strtolower(substr($line, 0, strlen($propname)))) {
6321 6321
           $newProp = TRUE;
6322 6322
           break;
6323 6323
         }
6324 6324
       }
6325
-      if( $newProp ) {
6325
+      if ($newProp) {
6326 6326
         $newProp = FALSE;
6327 6327
         $lastix++;
6328
-        $proprows[$lastix]  = $line;
6328
+        $proprows[$lastix] = $line;
6329 6329
       }
6330 6330
       else {
6331 6331
             /* remove line breaks */
6332
-        if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6333
-           (  ' ' == substr( $line, 0, 1 ))) {
6334
-          $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
6335
-          $line = substr( $line, 1 );
6332
+        if (('\n' == substr($proprows[$lastix], -2)) &&
6333
+           (' ' == substr($line, 0, 1))) {
6334
+          $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2);
6335
+          $line = substr($line, 1);
6336 6336
         }
6337 6337
         $proprows[$lastix] .= $line;
6338 6338
       }
6339 6339
     }
6340 6340
             /* parse each property 'line' */
6341
-    foreach( $proprows as $line ) {
6342
-      $line = str_replace( "\n ", '', $line );
6343
-      if( '\n' == substr( $line, -2 ))
6344
-        $line = substr( $line, 0, strlen( $line ) - 2 );
6341
+    foreach ($proprows as $line) {
6342
+      $line = str_replace("\n ", '', $line);
6343
+      if ('\n' == substr($line, -2))
6344
+        $line = substr($line, 0, strlen($line) - 2);
6345 6345
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6346 6346
       $cix = $propname = null;
6347
-      for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6348
-        if( in_array( $line{$cix}, array( ':', ';' )))
6347
+      for ($cix = 0; $cix < strlen($line); $cix++) {
6348
+        if (in_array($line{$cix}, array(':', ';')))
6349 6349
           break;
6350 6350
         else {
6351 6351
           $propname .= $line{$cix};
6352 6352
         }
6353 6353
       }
6354
-      if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) {
6354
+      if (('x-' == substr($propname, 0, 2)) || ('X-' == substr($propname, 0, 2))) {
6355 6355
         $propname2 = $propname;
6356 6356
         $propname  = 'X-';
6357 6357
       }
6358 6358
             /* rest of the line is opt.params and value */
6359
-      $line = substr( $line, $cix );
6359
+      $line = substr($line, $cix);
6360 6360
             /* separate attributes from value */
6361 6361
       $attr   = array();
6362 6362
       $attrix = -1;
6363
-      $strlen = strlen( $line );
6364
-      for( $cix=0; $cix < $strlen; $cix++ ) {
6365
-        if((       ':'   == $line{$cix} )             &&
6366
-                 ( '://' != substr( $line, $cix, 3 )) &&
6367
-           ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
6363
+      $strlen = strlen($line);
6364
+      for ($cix = 0; $cix < $strlen; $cix++) {
6365
+        if ((':' == $line{$cix} ) &&
6366
+                 ('://' != substr($line, $cix, 3)) &&
6367
+           ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) {
6368 6368
           $attrEnd = TRUE;
6369
-          if(( $cix < ( $strlen - 4 )) &&
6370
-               ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
6371
-            for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
6372
-              if( '://' == substr( $line, $c2ix - 2, 3 )) {
6369
+          if (($cix < ($strlen - 4)) &&
6370
+               ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr??
6371
+            for ($c2ix = $cix; 3 < $c2ix; $c2ix--) {
6372
+              if ('://' == substr($line, $c2ix - 2, 3)) {
6373 6373
                 $attrEnd = FALSE;
6374 6374
                 break; // an URI with a portnr!!
6375 6375
               }
6376 6376
             }
6377 6377
           }
6378
-          if( $attrEnd) {
6379
-            $line = substr( $line, $cix + 1 );
6378
+          if ($attrEnd) {
6379
+            $line = substr($line, $cix + 1);
6380 6380
             break;
6381 6381
           }
6382 6382
         }
6383
-        if( ';' == $line{$cix} )
6383
+        if (';' == $line{$cix} )
6384 6384
           $attr[++$attrix] = null;
6385 6385
         else
6386 6386
           $attr[$attrix] .= $line{$cix};
6387 6387
       }
6388 6388
             /* make attributes in array format */
6389 6389
       $propattr = array();
6390
-      foreach( $attr as $attribute ) {
6391
-        $attrsplit = explode( '=', $attribute, 2 );
6392
-        if( 1 < count( $attrsplit ))
6390
+      foreach ($attr as $attribute) {
6391
+        $attrsplit = explode('=', $attribute, 2);
6392
+        if (1 < count($attrsplit))
6393 6393
           $propattr[$attrsplit[0]] = $attrsplit[1];
6394 6394
         else
6395 6395
           $propattr[] = $attribute;
6396 6396
       }
6397 6397
             /* call setProperty( $propname.. . */
6398
-      switch( $propname ) {
6398
+      switch ($propname) {
6399 6399
         case 'ATTENDEE':
6400
-          foreach( $propattr as $pix => $attr ) {
6401
-            $attr2 = explode( ',', $attr );
6402
-              if( 1 < count( $attr2 ))
6400
+          foreach ($propattr as $pix => $attr) {
6401
+            $attr2 = explode(',', $attr);
6402
+              if (1 < count($attr2))
6403 6403
                 $propattr[$pix] = $attr2;
6404 6404
           }
6405
-          $this->setProperty( $propname, $line, $propattr );
6405
+          $this->setProperty($propname, $line, $propattr);
6406 6406
           break;
6407 6407
         case 'CATEGORIES':
6408 6408
         case 'RESOURCES':
6409
-          if( FALSE !== strpos( $line, ',' )) {
6410
-            $content  = explode( ',', $line );
6411
-            $clen     = count( $content );
6412
-            for( $cix = 0; $cix < $clen; $cix++ ) {
6413
-              if( "\\" == substr($content[$cix], -1)) {
6409
+          if (FALSE !== strpos($line, ',')) {
6410
+            $content  = explode(',', $line);
6411
+            $clen     = count($content);
6412
+            for ($cix = 0; $cix < $clen; $cix++) {
6413
+              if ("\\" == substr($content[$cix], -1)) {
6414 6414
                 $content[$cix] .= ','.$content[$cix + 1];
6415 6415
                 unset($content[$cix + 1]);
6416 6416
                 $cix++;
6417 6417
               }
6418 6418
             }
6419
-            if( 1 < count( $content )) {
6420
-              $content = array_values( $content );
6421
-              foreach( $content as $cix => $contentPart )
6422
-                $content[$cix] = $this->_strunrep( $contentPart );
6423
-              $this->setProperty( $propname, $content, $propattr );
6419
+            if (1 < count($content)) {
6420
+              $content = array_values($content);
6421
+              foreach ($content as $cix => $contentPart)
6422
+                $content[$cix] = $this->_strunrep($contentPart);
6423
+              $this->setProperty($propname, $content, $propattr);
6424 6424
               break;
6425 6425
             }
6426 6426
             else
6427
-              $line = reset( $content );
6427
+              $line = reset($content);
6428 6428
           }
6429 6429
         case 'X-':
6430
-          $propname = ( isset( $propname2 )) ? $propname2 : $propname;
6430
+          $propname = (isset($propname2)) ? $propname2 : $propname;
6431 6431
         case 'COMMENT':
6432 6432
         case 'CONTACT':
6433 6433
         case 'DESCRIPTION':
6434 6434
         case 'LOCATION':
6435 6435
         case 'SUMMARY':
6436
-          if( empty( $line ))
6436
+          if (empty($line))
6437 6437
             $propattr = null;
6438
-          $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6439
-          unset( $propname2 );
6438
+          $this->setProperty($propname, $this->_strunrep($line), $propattr);
6439
+          unset($propname2);
6440 6440
           break;
6441 6441
         case 'REQUEST-STATUS':
6442
-          $values    = explode( ';', $line, 3 );
6443
-          $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] );
6444
-          $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] );
6445
-          $this->setProperty( $propname
6442
+          $values    = explode(';', $line, 3);
6443
+          $values[1] = (!isset($values[1])) ? null : $this->_strunrep($values[1]);
6444
+          $values[2] = (!isset($values[2])) ? null : $this->_strunrep($values[2]);
6445
+          $this->setProperty($propname
6446 6446
                             , $values[0]  // statcode
6447 6447
                             , $values[1]  // statdesc
6448 6448
                             , $values[2]  // extdata
6449
-                            , $propattr );
6449
+                            , $propattr);
6450 6450
           break;
6451 6451
         case 'FREEBUSY':
6452
-          $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing
6453
-          unset( $propattr['FBTYPE'] );
6454
-          $values = explode( ',', $line );
6455
-          foreach( $values as $vix => $value ) {
6456
-            $value2 = explode( '/', $value );
6457
-            if( 1 < count( $value2 ))
6452
+          $fbtype = (isset($propattr['FBTYPE'])) ? $propattr['FBTYPE'] : ''; // force setting default, if missing
6453
+          unset($propattr['FBTYPE']);
6454
+          $values = explode(',', $line);
6455
+          foreach ($values as $vix => $value) {
6456
+            $value2 = explode('/', $value);
6457
+            if (1 < count($value2))
6458 6458
               $values[$vix] = $value2;
6459 6459
           }
6460
-          $this->setProperty( $propname, $fbtype, $values, $propattr );
6460
+          $this->setProperty($propname, $fbtype, $values, $propattr);
6461 6461
           break;
6462 6462
         case 'GEO':
6463
-          $value = explode( ';', $line, 2 );
6464
-          if( 2 > count( $value ))
6463
+          $value = explode(';', $line, 2);
6464
+          if (2 > count($value))
6465 6465
             $value[1] = null;
6466
-          $this->setProperty( $propname, $value[0], $value[1], $propattr );
6466
+          $this->setProperty($propname, $value[0], $value[1], $propattr);
6467 6467
           break;
6468 6468
         case 'EXDATE':
6469
-          $values = ( !empty( $line )) ? explode( ',', $line ) : null;
6470
-          $this->setProperty( $propname, $values, $propattr );
6469
+          $values = (!empty($line)) ? explode(',', $line) : null;
6470
+          $this->setProperty($propname, $values, $propattr);
6471 6471
           break;
6472 6472
         case 'RDATE':
6473
-          if( empty( $line )) {
6474
-            $this->setProperty( $propname, $line, $propattr );
6473
+          if (empty($line)) {
6474
+            $this->setProperty($propname, $line, $propattr);
6475 6475
             break;
6476 6476
           }
6477
-          $values = explode( ',', $line );
6478
-          foreach( $values as $vix => $value ) {
6479
-            $value2 = explode( '/', $value );
6480
-            if( 1 < count( $value2 ))
6477
+          $values = explode(',', $line);
6478
+          foreach ($values as $vix => $value) {
6479
+            $value2 = explode('/', $value);
6480
+            if (1 < count($value2))
6481 6481
               $values[$vix] = $value2;
6482 6482
           }
6483
-          $this->setProperty( $propname, $values, $propattr );
6483
+          $this->setProperty($propname, $values, $propattr);
6484 6484
           break;
6485 6485
         case 'EXRULE':
6486 6486
         case 'RRULE':
6487
-          $values = explode( ';', $line );
6487
+          $values = explode(';', $line);
6488 6488
           $recur = array();
6489
-          foreach( $values as $value2 ) {
6490
-            if( empty( $value2 ))
6489
+          foreach ($values as $value2) {
6490
+            if (empty($value2))
6491 6491
               continue; // ;-char in ending position ???
6492
-            $value3 = explode( '=', $value2, 2 );
6493
-            $rulelabel = strtoupper( $value3[0] );
6494
-            switch( $rulelabel ) {
6492
+            $value3 = explode('=', $value2, 2);
6493
+            $rulelabel = strtoupper($value3[0]);
6494
+            switch ($rulelabel) {
6495 6495
               case 'BYDAY': {
6496
-                $value4 = explode( ',', $value3[1] );
6497
-                if( 1 < count( $value4 )) {
6498
-                  foreach( $value4 as $v5ix => $value5 ) {
6496
+                $value4 = explode(',', $value3[1]);
6497
+                if (1 < count($value4)) {
6498
+                  foreach ($value4 as $v5ix => $value5) {
6499 6499
                     $value6 = array();
6500 6500
                     $dayno = $dayname = null;
6501
-                    $value5 = trim( (string) $value5 );
6502
-                    if(( ctype_alpha( substr( $value5, -1 ))) &&
6503
-                       ( ctype_alpha( substr( $value5, -2, 1 )))) {
6504
-                      $dayname = substr( $value5, -2, 2 );
6505
-                      if( 2 < strlen( $value5 ))
6506
-                        $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6501
+                    $value5 = trim((string) $value5);
6502
+                    if ((ctype_alpha(substr($value5, -1))) &&
6503
+                       (ctype_alpha(substr($value5, -2, 1)))) {
6504
+                      $dayname = substr($value5, -2, 2);
6505
+                      if (2 < strlen($value5))
6506
+                        $dayno = substr($value5, 0, (strlen($value5) - 2));
6507 6507
                     }
6508
-                    if( $dayno )
6508
+                    if ($dayno)
6509 6509
                       $value6[] = $dayno;
6510
-                    if( $dayname )
6510
+                    if ($dayname)
6511 6511
                       $value6['DAY'] = $dayname;
6512 6512
                     $value4[$v5ix] = $value6;
6513 6513
                   }
@@ -6515,41 +6515,41 @@  discard block
 block discarded – undo
6515 6515
                 else {
6516 6516
                   $value4 = array();
6517 6517
                   $dayno  = $dayname = null;
6518
-                  $value5 = trim( (string) $value3[1] );
6519
-                  if(( ctype_alpha( substr( $value5, -1 ))) &&
6520
-                     ( ctype_alpha( substr( $value5, -2, 1 )))) {
6521
-                      $dayname = substr( $value5, -2, 2 );
6522
-                    if( 2 < strlen( $value5 ))
6523
-                      $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6518
+                  $value5 = trim((string) $value3[1]);
6519
+                  if ((ctype_alpha(substr($value5, -1))) &&
6520
+                     (ctype_alpha(substr($value5, -2, 1)))) {
6521
+                      $dayname = substr($value5, -2, 2);
6522
+                    if (2 < strlen($value5))
6523
+                      $dayno = substr($value5, 0, (strlen($value5) - 2));
6524 6524
                   }
6525
-                  if( $dayno )
6525
+                  if ($dayno)
6526 6526
                     $value4[] = $dayno;
6527
-                  if( $dayname )
6527
+                  if ($dayname)
6528 6528
                     $value4['DAY'] = $dayname;
6529 6529
                 }
6530 6530
                 $recur[$rulelabel] = $value4;
6531 6531
                 break;
6532 6532
               }
6533 6533
               default: {
6534
-                $value4 = explode( ',', $value3[1] );
6535
-                if( 1 < count( $value4 ))
6534
+                $value4 = explode(',', $value3[1]);
6535
+                if (1 < count($value4))
6536 6536
                   $value3[1] = $value4;
6537 6537
                 $recur[$rulelabel] = $value3[1];
6538 6538
                 break;
6539 6539
               }
6540 6540
             } // end - switch $rulelabel
6541 6541
           } // end - foreach( $values.. .
6542
-          $this->setProperty( $propname, $recur, $propattr );
6542
+          $this->setProperty($propname, $recur, $propattr);
6543 6543
           break;
6544 6544
         default:
6545
-          $this->setProperty( $propname, $line, $propattr );
6545
+          $this->setProperty($propname, $line, $propattr);
6546 6546
           break;
6547 6547
       } // end  switch( $propname.. .
6548 6548
     } // end - foreach( $proprows.. .
6549
-    unset( $this->unparsed, $proprows );
6550
-    if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6551
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
6552
-        if( !empty( $this->components[$six]->unparsed ))
6549
+    unset($this->unparsed, $proprows);
6550
+    if (isset($this->components) && is_array($this->components) && (0 < count($this->components))) {
6551
+      for ($six = 0; $six < count($this->components); $six++) {
6552
+        if (!empty($this->components[$six]->unparsed))
6553 6553
           $this->components[$six]->parse();
6554 6554
       }
6555 6555
     }
@@ -6566,7 +6566,7 @@  discard block
 block discarded – undo
6566 6566
   function copy() {
6567 6567
     $serialized_contents = serialize($this);
6568 6568
     $copy = unserialize($serialized_contents);
6569
-    unset( $copy->propix );
6569
+    unset($copy->propix);
6570 6570
     return $copy;
6571 6571
  }
6572 6572
 /*********************************************************************************/
@@ -6580,34 +6580,34 @@  discard block
 block discarded – undo
6580 6580
  * @param mixed $arg2 optional, ordno if arg1 = component type
6581 6581
  * @return void
6582 6582
  */
6583
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
6584
-    if( !isset( $this->components )) return FALSE;
6583
+  function deleteComponent($arg1, $arg2 = FALSE) {
6584
+    if (!isset($this->components)) return FALSE;
6585 6585
     $argType = $index = null;
6586
-    if ( ctype_digit( (string) $arg1 )) {
6586
+    if (ctype_digit((string) $arg1)) {
6587 6587
       $argType = 'INDEX';
6588 6588
       $index   = (int) $arg1 - 1;
6589 6589
     }
6590
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6591
-      $argType = strtolower( $arg1 );
6592
-      $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6590
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
6591
+      $argType = strtolower($arg1);
6592
+      $index   = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0;
6593 6593
     }
6594 6594
     $cix2dC = 0;
6595
-    foreach ( $this->components as $cix => $component) {
6596
-      if( empty( $component )) continue;
6597
-      unset( $component->propix );
6598
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6599
-        unset( $this->components[$cix] );
6595
+    foreach ($this->components as $cix => $component) {
6596
+      if (empty($component)) continue;
6597
+      unset($component->propix);
6598
+      if (('INDEX' == $argType) && ($index == $cix)) {
6599
+        unset($this->components[$cix]);
6600 6600
         return TRUE;
6601 6601
       }
6602
-      elseif( $argType == $component->objName ) {
6603
-        if( $index == $cix2dC ) {
6604
-          unset( $this->components[$cix] );
6602
+      elseif ($argType == $component->objName) {
6603
+        if ($index == $cix2dC) {
6604
+          unset($this->components[$cix]);
6605 6605
           return TRUE;
6606 6606
         }
6607 6607
         $cix2dC++;
6608 6608
       }
6609
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6610
-        unset( $this->components[$cix] );
6609
+      elseif (!$argType && ($arg1 == $component->getProperty('uid'))) {
6610
+        unset($this->components[$cix]);
6611 6611
         return TRUE;
6612 6612
       }
6613 6613
     }
@@ -6622,50 +6622,50 @@  discard block
 block discarded – undo
6622 6622
  * @param mixed $arg2 optional, ordno if arg1 = component type
6623 6623
  * @return object
6624 6624
  */
6625
-  function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6626
-    if( !isset( $this->components )) return FALSE;
6625
+  function getComponent($arg1 = FALSE, $arg2 = FALSE) {
6626
+    if (!isset($this->components)) return FALSE;
6627 6627
     $index = $argType = null;
6628
-    if ( !$arg1 ) {
6628
+    if (!$arg1) {
6629 6629
       $argType = 'INDEX';
6630 6630
       $index   = $this->compix['INDEX'] =
6631
-        ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6631
+        (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1;
6632 6632
     }
6633
-    elseif ( ctype_digit( (string) $arg1 )) {
6633
+    elseif (ctype_digit((string) $arg1)) {
6634 6634
       $argType = 'INDEX';
6635 6635
       $index   = (int) $arg1;
6636
-      unset( $this->compix );
6636
+      unset($this->compix);
6637 6637
     }
6638
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6639
-      unset( $this->compix['INDEX'] );
6640
-      $argType = strtolower( $arg1 );
6641
-      if( !$arg2 )
6638
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
6639
+      unset($this->compix['INDEX']);
6640
+      $argType = strtolower($arg1);
6641
+      if (!$arg2)
6642 6642
         $index = $this->compix[$argType] =
6643
-        ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6643
+        (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1;
6644 6644
       else
6645 6645
         $index = (int) $arg2;
6646 6646
     }
6647
-    $index  -= 1;
6648
-    $ckeys = array_keys( $this->components );
6649
-    if( !empty( $index) && ( $index > end( $ckeys )))
6647
+    $index -= 1;
6648
+    $ckeys = array_keys($this->components);
6649
+    if (!empty($index) && ($index > end($ckeys)))
6650 6650
       return FALSE;
6651 6651
     $cix2gC = 0;
6652
-    foreach( $this->components as $cix => $component ) {
6653
-      if( empty( $component )) continue;
6654
-      unset( $component->propix );
6655
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
6652
+    foreach ($this->components as $cix => $component) {
6653
+      if (empty($component)) continue;
6654
+      unset($component->propix);
6655
+      if (('INDEX' == $argType) && ($index == $cix))
6656 6656
         return $component->copy();
6657
-      elseif( $argType == $component->objName ) {
6658
-         if( $index == $cix2gC )
6657
+      elseif ($argType == $component->objName) {
6658
+         if ($index == $cix2gC)
6659 6659
            return $component->copy();
6660 6660
          $cix2gC++;
6661 6661
       }
6662
-      elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6663
-        unset( $component->propix );
6662
+      elseif (!$argType && ($arg1 == $component->getProperty('uid'))) {
6663
+        unset($component->propix);
6664 6664
         return $component->copy();
6665 6665
       }
6666 6666
     }
6667 6667
             /* not found.. . */
6668
-    unset( $this->compix );
6668
+    unset($this->compix);
6669 6669
     return false;
6670 6670
   }
6671 6671
 /**
@@ -6676,8 +6676,8 @@  discard block
 block discarded – undo
6676 6676
  * @param object $component calendar component
6677 6677
  * @return void
6678 6678
  */
6679
-  function addSubComponent ( $component ) {
6680
-    $this->setComponent( $component );
6679
+  function addSubComponent($component) {
6680
+    $this->setComponent($component);
6681 6681
   }
6682 6682
 /**
6683 6683
  * add calendar component as subcomponent to container for subcomponents
@@ -6689,49 +6689,49 @@  discard block
 block discarded – undo
6689 6689
  * @param mixed $arg2 optional, ordno if arg1 = component type
6690 6690
  * @return bool
6691 6691
  */
6692
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6693
-    if( !isset( $this->components )) return FALSE;
6694
-    if( '' >= $component->getConfig( 'language'))
6695
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
6696
-    $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6697
-    $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6698
-    $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6699
-    $component->setConfig( 'format',      $this->getConfig( 'format' ));
6700
-    if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6701
-      unset( $component->propix );
6692
+  function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) {
6693
+    if (!isset($this->components)) return FALSE;
6694
+    if ('' >= $component->getConfig('language'))
6695
+      $component->setConfig('language', $this->getConfig('language'));
6696
+    $component->setConfig('allowEmpty', $this->getConfig('allowEmpty'));
6697
+    $component->setConfig('nl', $this->getConfig('nl'));
6698
+    $component->setConfig('unique_id', $this->getConfig('unique_id'));
6699
+    $component->setConfig('format', $this->getConfig('format'));
6700
+    if (!in_array($component->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) {
6701
+      unset($component->propix);
6702 6702
             /* make sure dtstamp and uid is set */
6703
-      $dummy = $component->getProperty( 'dtstamp' );
6704
-      $dummy = $component->getProperty( 'uid' );
6703
+      $dummy = $component->getProperty('dtstamp');
6704
+      $dummy = $component->getProperty('uid');
6705 6705
     }
6706
-    if( !$arg1 ) {
6706
+    if (!$arg1) {
6707 6707
       $this->components[] = $component->copy();
6708 6708
       return TRUE;
6709 6709
     }
6710 6710
     $argType = $index = null;
6711
-    if ( ctype_digit( (string) $arg1 )) {
6711
+    if (ctype_digit((string) $arg1)) {
6712 6712
       $argType = 'INDEX';
6713 6713
       $index   = (int) $arg1 - 1;
6714 6714
     }
6715
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6716
-      $argType = strtolower( $arg1 );
6717
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6715
+    elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) {
6716
+      $argType = strtolower($arg1);
6717
+      $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0;
6718 6718
     }
6719 6719
     $cix2sC = 0;
6720
-    foreach ( $this->components as $cix => $component2 ) {
6721
-      if( empty( $component2 )) continue;
6722
-      unset( $component2->propix );
6723
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6720
+    foreach ($this->components as $cix => $component2) {
6721
+      if (empty($component2)) continue;
6722
+      unset($component2->propix);
6723
+      if (('INDEX' == $argType) && ($index == $cix)) {
6724 6724
         $this->components[$cix] = $component->copy();
6725 6725
         return TRUE;
6726 6726
       }
6727
-      elseif( $argType == $component2->objName ) {
6728
-        if( $index == $cix2sC ) {
6727
+      elseif ($argType == $component2->objName) {
6728
+        if ($index == $cix2sC) {
6729 6729
           $this->components[$cix] = $component->copy();
6730 6730
           return TRUE;
6731 6731
         }
6732 6732
         $cix2sC++;
6733 6733
       }
6734
-      elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6734
+      elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) {
6735 6735
         $this->components[$cix] = $component->copy();
6736 6736
         return TRUE;
6737 6737
       }
@@ -6749,15 +6749,15 @@  discard block
 block discarded – undo
6749 6749
  */
6750 6750
   function createSubComponent() {
6751 6751
     $output = null;
6752
-    foreach( $this->components as $component ) {
6753
-      if( empty( $component )) continue;
6754
-      if( '' >= $component->getConfig( 'language'))
6755
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
6756
-      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6757
-      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6758
-      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6759
-      $component->setConfig( 'format',      $this->getConfig( 'format' ));
6760
-      $output .= $component->createComponent( $this->xcaldecl );
6752
+    foreach ($this->components as $component) {
6753
+      if (empty($component)) continue;
6754
+      if ('' >= $component->getConfig('language'))
6755
+        $component->setConfig('language', $this->getConfig('language'));
6756
+      $component->setConfig('allowEmpty', $this->getConfig('allowEmpty'));
6757
+      $component->setConfig('nl', $this->getConfig('nl'));
6758
+      $component->setConfig('unique_id', $this->getConfig('unique_id'));
6759
+      $component->setConfig('format', $this->getConfig('format'));
6760
+      $output .= $component->createComponent($this->xcaldecl);
6761 6761
     }
6762 6762
     return $output;
6763 6763
   }
@@ -6784,21 +6784,21 @@  discard block
 block discarded – undo
6784 6784
  * @param string $value
6785 6785
  * @return string
6786 6786
  */
6787
-  function _size75( $string ) {
6788
-    $strlen = strlen( $string );
6787
+  function _size75($string) {
6788
+    $strlen = strlen($string);
6789 6789
     $tmp    = $string;
6790 6790
     $string = null;
6791
-    while( $strlen > 75 ) {
6791
+    while ($strlen > 75) {
6792 6792
        $breakAtChar = 75;
6793
-       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6793
+       if (substr($tmp, ($breakAtChar - 1), strlen('\n')) == '\n')
6794 6794
          $breakAtChar = $breakAtChar - 1;
6795
-       $string .= substr( $tmp, 0, $breakAtChar );
6795
+       $string .= substr($tmp, 0, $breakAtChar);
6796 6796
        $string .= $this->nl;
6797
-       $tmp     = ' '.substr( $tmp, $breakAtChar );
6798
-       $strlen  = strlen( $tmp );
6797
+       $tmp     = ' '.substr($tmp, $breakAtChar);
6798
+       $strlen  = strlen($tmp);
6799 6799
     } // while
6800
-    $string .= rtrim( $tmp ); // the rest
6801
-    if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6800
+    $string .= rtrim($tmp); // the rest
6801
+    if ($this->nl != substr($string, (0 - strlen($this->nl))))
6802 6802
       $string .= $this->nl;
6803 6803
     return $string;
6804 6804
   }
@@ -6810,38 +6810,38 @@  discard block
 block discarded – undo
6810 6810
  * @param string $string
6811 6811
  * @return string
6812 6812
  */
6813
-  function _strrep( $string ) {
6814
-    switch( $this->format ) {
6813
+  function _strrep($string) {
6814
+    switch ($this->format) {
6815 6815
       case 'xcal':
6816
-        $string = str_replace( '\n',  $this->nl, $string);
6817
-        $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string ))));
6816
+        $string = str_replace('\n', $this->nl, $string);
6817
+        $string = htmlspecialchars(strip_tags(stripslashes(urldecode($string))));
6818 6818
         break;
6819 6819
       default:
6820 6820
         $pos = 0;
6821
-        while( $pos <= strlen( $string )) {
6822
-          $pos = strpos( $string, "\\", $pos );
6823
-          if( FALSE === $pos )
6821
+        while ($pos <= strlen($string)) {
6822
+          $pos = strpos($string, "\\", $pos);
6823
+          if (FALSE === $pos)
6824 6824
             break;
6825
-          if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6826
-            $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6825
+          if (!in_array($string{($pos + 1)}, array('n', 'N', 'r', ',', ';'))) {
6826
+            $string = substr($string, 0, $pos)."\\".substr($string, ($pos + 1));
6827 6827
             $pos += 1;
6828 6828
           }
6829 6829
           $pos += 1;
6830 6830
         }
6831
-        if( FALSE !== strpos( $string, '"' ))
6832
-          $string = str_replace('"',   "'",       $string);
6833
-        if( FALSE !== strpos( $string, ',' ))
6834
-          $string = str_replace(',',   '\,',      $string);
6835
-        if( FALSE !== strpos( $string, ';' ))
6836
-          $string = str_replace(';',   '\;',      $string);
6837
-        if( FALSE !== strpos( $string, "\r\n" ))
6838
-          $string = str_replace( "\r\n", '\n',    $string);
6839
-        elseif( FALSE !== strpos( $string, "\r" ))
6840
-          $string = str_replace( "\r", '\n',      $string);
6841
-        if( FALSE !== strpos( $string, '\N' ))
6842
-          $string = str_replace( '\N', '\n',      $string);
6831
+        if (FALSE !== strpos($string, '"'))
6832
+          $string = str_replace('"', "'", $string);
6833
+        if (FALSE !== strpos($string, ','))
6834
+          $string = str_replace(',', '\,', $string);
6835
+        if (FALSE !== strpos($string, ';'))
6836
+          $string = str_replace(';', '\;', $string);
6837
+        if (FALSE !== strpos($string, "\r\n"))
6838
+          $string = str_replace("\r\n", '\n', $string);
6839
+        elseif (FALSE !== strpos($string, "\r"))
6840
+          $string = str_replace("\r", '\n', $string);
6841
+        if (FALSE !== strpos($string, '\N'))
6842
+          $string = str_replace('\N', '\n', $string);
6843 6843
 //        if( FALSE !== strpos( $string, $this->nl ))
6844
-          $string = str_replace( $this->nl, '\n', $string);
6844
+          $string = str_replace($this->nl, '\n', $string);
6845 6845
         break;
6846 6846
     }
6847 6847
     return $string;
@@ -6854,10 +6854,10 @@  discard block
 block discarded – undo
6854 6854
  * @param string $string
6855 6855
  * @return string
6856 6856
  */
6857
-  function _strunrep( $string ) {
6858
-    $string = str_replace( '\\\\', '\\',     $string);
6859
-    $string = str_replace( '\,',   ',',      $string);
6860
-    $string = str_replace( '\;',   ';',      $string);
6857
+  function _strunrep($string) {
6858
+    $string = str_replace('\\\\', '\\', $string);
6859
+    $string = str_replace('\,', ',', $string);
6860
+    $string = str_replace('\;', ';', $string);
6861 6861
 //    $string = str_replace( '\n',  $this->nl, $string); // ??
6862 6862
     return $string;
6863 6863
   }
@@ -6955,7 +6955,7 @@  discard block
 block discarded – undo
6955 6955
  * @param array $xcaldecl
6956 6956
  * @return string
6957 6957
  */
6958
-  function createComponent( &$xcaldecl ) {
6958
+  function createComponent(&$xcaldecl) {
6959 6959
     $objectname    = $this->_createFormat();
6960 6960
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
6961 6961
     $component    .= $this->createUid();
@@ -6992,8 +6992,8 @@  discard block
 block discarded – undo
6992 6992
     $component    .= $this->createXprop();
6993 6993
     $component    .= $this->createSubComponent();
6994 6994
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
6995
-    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
6996
-      foreach( $this->xcaldecl as $localxcaldecl )
6995
+    if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) {
6996
+      foreach ($this->xcaldecl as $localxcaldecl)
6997 6997
         $xcaldecl[] = $localxcaldecl;
6998 6998
     }
6999 6999
     return $component;
@@ -7093,7 +7093,7 @@  discard block
 block discarded – undo
7093 7093
  * @param array $xcaldecl
7094 7094
  * @return string
7095 7095
  */
7096
-  function createComponent( &$xcaldecl ) {
7096
+  function createComponent(&$xcaldecl) {
7097 7097
     $objectname    = $this->_createFormat();
7098 7098
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7099 7099
     $component    .= $this->createUid();
@@ -7131,8 +7131,8 @@  discard block
 block discarded – undo
7131 7131
     $component    .= $this->createXprop();
7132 7132
     $component    .= $this->createSubComponent();
7133 7133
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7134
-    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7135
-      foreach( $this->xcaldecl as $localxcaldecl )
7134
+    if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) {
7135
+      foreach ($this->xcaldecl as $localxcaldecl)
7136 7136
         $xcaldecl[] = $localxcaldecl;
7137 7137
     }
7138 7138
     return $component;
@@ -7212,7 +7212,7 @@  discard block
 block discarded – undo
7212 7212
  * @param array $xcaldecl
7213 7213
  * @return string
7214 7214
  */
7215
-  function createComponent( &$xcaldecl ) {
7215
+  function createComponent(&$xcaldecl) {
7216 7216
     $objectname = $this->_createFormat();
7217 7217
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7218 7218
     $component .= $this->createUid();
@@ -7241,8 +7241,8 @@  discard block
 block discarded – undo
7241 7241
     $component .= $this->createUrl();
7242 7242
     $component .= $this->createXprop();
7243 7243
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7244
-    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7245
-      foreach( $this->xcaldecl as $localxcaldecl )
7244
+    if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) {
7245
+      foreach ($this->xcaldecl as $localxcaldecl)
7246 7246
         $xcaldecl[] = $localxcaldecl;
7247 7247
     }
7248 7248
     return $component;
@@ -7300,7 +7300,7 @@  discard block
 block discarded – undo
7300 7300
  * @param array $xcaldecl
7301 7301
  * @return string
7302 7302
  */
7303
-  function createComponent( &$xcaldecl ) {
7303
+  function createComponent(&$xcaldecl) {
7304 7304
     $objectname = $this->_createFormat();
7305 7305
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7306 7306
     $component .= $this->createUid();
@@ -7317,8 +7317,8 @@  discard block
 block discarded – undo
7317 7317
     $component .= $this->createUrl();
7318 7318
     $component .= $this->createXprop();
7319 7319
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7320
-    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7321
-      foreach( $this->xcaldecl as $localxcaldecl )
7320
+    if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) {
7321
+      foreach ($this->xcaldecl as $localxcaldecl)
7322 7322
         $xcaldecl[] = $localxcaldecl;
7323 7323
     }
7324 7324
     return $component;
@@ -7370,7 +7370,7 @@  discard block
 block discarded – undo
7370 7370
  * @param array $xcaldecl
7371 7371
  * @return string
7372 7372
  */
7373
-  function createComponent( &$xcaldecl ) {
7373
+  function createComponent(&$xcaldecl) {
7374 7374
     $objectname    = $this->_createFormat();
7375 7375
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7376 7376
     $component    .= $this->createAction();
@@ -7418,11 +7418,11 @@  discard block
 block discarded – undo
7418 7418
  * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT )
7419 7419
  * @return void
7420 7420
  */
7421
-  function vtimezone( $timezonetype=FALSE ) {
7422
-    if( !$timezonetype )
7421
+  function vtimezone($timezonetype = FALSE) {
7422
+    if (!$timezonetype)
7423 7423
       $this->timezonetype = 'VTIMEZONE';
7424 7424
     else
7425
-      $this->timezonetype = strtoupper( $timezonetype );
7425
+      $this->timezonetype = strtoupper($timezonetype);
7426 7426
     $this->calendarComponent();
7427 7427
 
7428 7428
     $this->comment         = '';
@@ -7447,7 +7447,7 @@  discard block
 block discarded – undo
7447 7447
  * @param array $xcaldecl
7448 7448
  * @return string
7449 7449
  */
7450
-  function createComponent( &$xcaldecl ) {
7450
+  function createComponent(&$xcaldecl) {
7451 7451
     $objectname    = $this->_createFormat();
7452 7452
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7453 7453
     $component    .= $this->createTzid();
@@ -7463,8 +7463,8 @@  discard block
 block discarded – undo
7463 7463
     $component    .= $this->createXprop();
7464 7464
     $component    .= $this->createSubComponent();
7465 7465
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7466
-    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7467
-      foreach( $this->xcaldecl as $localxcaldecl )
7466
+    if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) {
7467
+      foreach ($this->xcaldecl as $localxcaldecl)
7468 7468
         $xcaldecl[] = $localxcaldecl;
7469 7469
     }
7470 7470
     return $component;
Please login to merge, or discard this patch.
Braces   +2276 added lines, -1351 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
 /*********************************************************************************/
@@ -97,8 +99,9 @@  discard block
 block discarded – undo
97 99
 /**
98 100
  *   language = <Text identifying a language, as defined in [RFC 1766]>
99 101
  */
100
-    if( defined( 'ICAL_LANG' ))
101
-      $this->setConfig( 'language', ICAL_LANG );
102
+    if( defined( 'ICAL_LANG' )) {
103
+          $this->setConfig( 'language', ICAL_LANG );
104
+    }
102 105
     $this->setConfig( 'allowEmpty', TRUE );
103 106
     $this->setConfig( 'nl',         "\n" );
104 107
     $this->setConfig( 'format',     'iCal');
@@ -121,7 +124,9 @@  discard block
 block discarded – undo
121 124
  * @return string
122 125
  */
123 126
   function createCalscale() {
124
-    if( empty( $this->calscale )) return FALSE;
127
+    if( empty( $this->calscale )) {
128
+        return FALSE;
129
+    }
125 130
     switch( $this->format ) {
126 131
       case 'xcal':
127 132
         return ' calscale="'.$this->calscale.'"'.$this->nl;
@@ -140,7 +145,9 @@  discard block
 block discarded – undo
140 145
  * @return void
141 146
  */
142 147
   function setCalscale( $value ) {
143
-    if( empty( $value )) return FALSE;
148
+    if( empty( $value )) {
149
+        return FALSE;
150
+    }
144 151
     $this->calscale = $value;
145 152
   }
146 153
 /*********************************************************************************/
@@ -155,7 +162,9 @@  discard block
 block discarded – undo
155 162
  * @return string
156 163
  */
157 164
   function createMethod() {
158
-    if( empty( $this->method )) return FALSE;
165
+    if( empty( $this->method )) {
166
+        return FALSE;
167
+    }
159 168
     switch( $this->format ) {
160 169
       case 'xcal':
161 170
         return ' method="'.$this->method.'"'.$this->nl;
@@ -174,7 +183,9 @@  discard block
 block discarded – undo
174 183
  * @return bool
175 184
  */
176 185
   function setMethod( $value ) {
177
-    if( empty( $value )) return FALSE;
186
+    if( empty( $value )) {
187
+        return FALSE;
188
+    }
178 189
     $this->method = $value;
179 190
     return TRUE;
180 191
   }
@@ -194,8 +205,9 @@  discard block
 block discarded – undo
194 205
  * @return string
195 206
  */
196 207
   function createProdid() {
197
-    if( !isset( $this->prodid ))
198
-      $this->_makeProdid();
208
+    if( !isset( $this->prodid )) {
209
+          $this->_makeProdid();
210
+    }
199 211
     switch( $this->format ) {
200 212
       case 'xcal':
201 213
         return ' prodid="'.$this->prodid.'"'.$this->nl;
@@ -246,8 +258,9 @@  discard block
 block discarded – undo
246 258
  * @return string
247 259
  */
248 260
   function createVersion() {
249
-    if( empty( $this->version ))
250
-      $this->_makeVersion();
261
+    if( empty( $this->version )) {
262
+          $this->_makeVersion();
263
+    }
251 264
     switch( $this->format ) {
252 265
       case 'xcal':
253 266
         return ' version="'.$this->version.'"'.$this->nl;
@@ -276,7 +289,9 @@  discard block
 block discarded – undo
276 289
  * @return void
277 290
  */
278 291
   function setVersion( $value ) {
279
-    if( empty( $value )) return FALSE;
292
+    if( empty( $value )) {
293
+        return FALSE;
294
+    }
280 295
     $this->version = $value;
281 296
     return TRUE;
282 297
   }
@@ -292,10 +307,12 @@  discard block
 block discarded – undo
292 307
  * @return string
293 308
  */
294 309
   function createXprop() {
295
-    if( 'xcal' == $this->format )
296
-      return false;
297
-    if( 0 >= count( $this->xprop ))
298
-      return;
310
+    if( 'xcal' == $this->format ) {
311
+          return false;
312
+    }
313
+    if( 0 >= count( $this->xprop )) {
314
+          return;
315
+    }
299 316
     $output = null;
300 317
     $toolbox = new calendarComponent();
301 318
     $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
@@ -308,12 +325,13 @@  discard block
 block discarded – undo
308 325
       }
309 326
       $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
310 327
       if( is_array( $xpropPart['value'] )) {
311
-        foreach( $xpropPart['value'] as $pix => $theXpart )
312
-          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
328
+        foreach( $xpropPart['value'] as $pix => $theXpart ) {
329
+                  $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
330
+        }
313 331
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
332
+      } else {
333
+              $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
314 334
       }
315
-      else
316
-        $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
317 335
       $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
318 336
     }
319 337
     return $output;
@@ -329,12 +347,20 @@  discard block
 block discarded – undo
329 347
  * @return bool
330 348
  */
331 349
   function setXprop( $label, $value, $params=FALSE ) {
332
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
333
-    if( empty( $label )) return FALSE;
350
+    if( empty( $value )) {
351
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
352
+    } else {
353
+        return FALSE;
354
+    }
355
+    if( empty( $label )) {
356
+        return FALSE;
357
+    }
334 358
     $xprop           = array( 'value' => $value );
335 359
     $toolbox         = new calendarComponent();
336 360
     $xprop['params'] = $toolbox->_setParams( $params );
337
-    if( !is_array( $this->xprop )) $this->xprop = array();
361
+    if( !is_array( $this->xprop )) {
362
+        $this->xprop = array();
363
+    }
338 364
     $this->xprop[strtoupper( $label )] = $xprop;
339 365
     return TRUE;
340 366
   }
@@ -350,8 +376,9 @@  discard block
 block discarded – undo
350 376
  */
351 377
   function deleteProperty( $propName, $propix=FALSE ) {
352 378
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
353
-    if( !$propix )
354
-      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
379
+    if( !$propix ) {
380
+          $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
381
+    }
355 382
     $this->propdelix[$propName] = --$propix;
356 383
     $return = FALSE;
357 384
     switch( $propName ) {
@@ -370,18 +397,23 @@  discard block
 block discarded – undo
370 397
       default:
371 398
         $reduced = array();
372 399
         if( $propName != 'X-PROP' ) {
373
-          if( !isset( $this->xprop[$propName] )) return FALSE;
400
+          if( !isset( $this->xprop[$propName] )) {
401
+              return FALSE;
402
+          }
374 403
           foreach( $this->xprop as $k => $a ) {
375
-            if(( $k != $propName ) && !empty( $a ))
376
-              $reduced[$k] = $a;
404
+            if(( $k != $propName ) && !empty( $a )) {
405
+                          $reduced[$k] = $a;
406
+            }
407
+          }
408
+        } else {
409
+          if( count( $this->xprop ) <= $propix ) {
410
+              return FALSE;
377 411
           }
378
-        }
379
-        else {
380
-          if( count( $this->xprop ) <= $propix )  return FALSE;
381 412
           $xpropno = 0;
382 413
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
383
-            if( $propix != $xpropno )
384
-              $reduced[$xpropkey] = $xpropvalue;
414
+            if( $propix != $xpropno ) {
415
+                          $reduced[$xpropkey] = $xpropvalue;
416
+            }
385 417
             $xpropno++;
386 418
           }
387 419
         }
@@ -403,8 +435,9 @@  discard block
 block discarded – undo
403 435
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
404 436
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
405 437
     if( 'X-PROP' == $propName ) {
406
-      if( !$propix )
407
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
438
+      if( !$propix ) {
439
+              $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
440
+      }
408 441
       $this->propix[$propName] = --$propix;
409 442
     }
410 443
     switch( $propName ) {
@@ -415,8 +448,9 @@  discard block
 block discarded – undo
415 448
         return ( !empty( $this->method )) ? $this->method : null;
416 449
         break;
417 450
       case 'PRODID':
418
-        if( empty( $this->prodid ))
419
-          $this->_makeProdid();
451
+        if( empty( $this->prodid )) {
452
+                  $this->_makeProdid();
453
+        }
420 454
         return $this->prodid;
421 455
         break;
422 456
       case 'VERSION':
@@ -424,19 +458,23 @@  discard block
 block discarded – undo
424 458
         break;
425 459
       default:
426 460
         if( $propName != 'X-PROP' ) {
427
-          if( !isset( $this->xprop[$propName] )) return FALSE;
461
+          if( !isset( $this->xprop[$propName] )) {
462
+              return FALSE;
463
+          }
428 464
           return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
429 465
                                 : array( $propName, $this->xprop[$propName]['value'] );
430
-        }
431
-        else {
432
-          if( empty( $this->xprop )) return FALSE;
466
+        } else {
467
+          if( empty( $this->xprop )) {
468
+              return FALSE;
469
+          }
433 470
           $xpropno = 0;
434 471
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
435
-            if( $propix == $xpropno )
436
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
472
+            if( $propix == $xpropno ) {
473
+                          return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
437 474
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
438
-            else
439
-              $xpropno++;
475
+            } else {
476
+                          $xpropno++;
477
+            }
440 478
           }
441 479
           return FALSE; // not found ??
442 480
         }
@@ -455,8 +493,9 @@  discard block
 block discarded – undo
455 493
  */
456 494
   function setProperty () {
457 495
     $numargs    = func_num_args();
458
-    if( 1 > $numargs )
459
-      return FALSE;
496
+    if( 1 > $numargs ) {
497
+          return FALSE;
498
+    }
460 499
     $arglist    = func_get_args();
461 500
     $arglist[0] = strtoupper( $arglist[0] );
462 501
     switch( $arglist[0] ) {
@@ -467,8 +506,12 @@  discard block
 block discarded – undo
467 506
       case 'VERSION':
468 507
         return $this->setVersion( $arglist[1] );
469 508
       default:
470
-        if( !isset( $arglist[1] )) $arglist[1] = null;
471
-        if( !isset( $arglist[2] )) $arglist[2] = null;
509
+        if( !isset( $arglist[1] )) {
510
+            $arglist[1] = null;
511
+        }
512
+        if( !isset( $arglist[2] )) {
513
+            $arglist[2] = null;
514
+        }
472 515
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
473 516
     }
474 517
     return FALSE;
@@ -491,7 +534,9 @@  discard block
 block discarded – undo
491 534
         unset( $this->compix );
492 535
         $info = array();
493 536
         foreach( $this->components as $cix => $component ) {
494
-          if( empty( $component )) continue;
537
+          if( empty( $component )) {
538
+              continue;
539
+          }
495 540
           unset( $component->propix );
496 541
           $info[$cix]['ordno'] = $cix + 1;
497 542
           $info[$cix]['type']  = $component->objName;
@@ -506,8 +551,9 @@  discard block
 block discarded – undo
506 551
         return $this->delimiter;
507 552
         break;
508 553
       case 'DIRECTORY':
509
-        if( empty( $this->directory ))
510
-          $this->directory = '.';
554
+        if( empty( $this->directory )) {
555
+                  $this->directory = '.';
556
+        }
511 557
         return $this->directory;
512 558
         break;
513 559
       case 'DIRFILE':
@@ -520,10 +566,13 @@  discard block
 block discarded – undo
520 566
         break;
521 567
       case 'FILENAME':
522 568
         if( empty( $this->filename )) {
523
-          if( 'xcal' == $this->format )
524
-            $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
525
-          else
526
-            $this->filename = date( 'YmdHis' ).'.ics';
569
+          if( 'xcal' == $this->format ) {
570
+                      $this->filename = date( 'YmdHis' ).'.xml';
571
+          }
572
+          // recommended xcs.. .
573
+          else {
574
+                      $this->filename = date( 'YmdHis' ).'.ics';
575
+          }
527 576
         }
528 577
         return $this->filename;
529 578
         break;
@@ -531,8 +580,9 @@  discard block
 block discarded – undo
531 580
         $size    = 0;
532 581
         if( empty( $this->url )) {
533 582
           $dirfile = $this->getConfig( 'dirfile' );
534
-          if( FALSE === ( $size = filesize( $dirfile )))
535
-            $size = 0;
583
+          if( FALSE === ( $size = filesize( $dirfile ))) {
584
+                      $size = 0;
585
+          }
536 586
           clearstatcache();
537 587
         }
538 588
         return $size;
@@ -552,10 +602,11 @@  discard block
 block discarded – undo
552 602
         return $this->unique_id;
553 603
         break;
554 604
       case 'URL':
555
-        if( !empty( $this->url ))
556
-          return $this->url;
557
-        else
558
-          return FALSE;
605
+        if( !empty( $this->url )) {
606
+                  return $this->url;
607
+        } else {
608
+                  return FALSE;
609
+        }
559 610
         break;
560 611
     }
561 612
   }
@@ -583,17 +634,18 @@  discard block
 block discarded – undo
583 634
       case 'DIRECTORY':
584 635
         $value   = trim( $value );
585 636
         $nl      = $this->getConfig('delimiter');
586
-        if( $nl == substr( $value, ( 0 - strlen( $nl ))))
587
-          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
637
+        if( $nl == substr( $value, ( 0 - strlen( $nl )))) {
638
+                  $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
639
+        }
588 640
         if( is_dir( $value )) {
589 641
             /* local directory */
590 642
           clearstatcache();
591 643
           $this->directory = $value;
592 644
           $this->url       = null;
593 645
           return TRUE;
646
+        } else {
647
+                  return FALSE;
594 648
         }
595
-        else
596
-          return FALSE;
597 649
         break;
598 650
       case 'FILENAME':
599 651
         $value   = trim( $value );
@@ -609,17 +661,16 @@  discard block
 block discarded – undo
609 661
             clearstatcache();
610 662
             $this->filename = $value;
611 663
             return TRUE;
664
+          } else {
665
+                      return FALSE;
612 666
           }
613
-          else
614
-            return FALSE;
615
-        }
616
-        elseif( FALSE !== touch( $dirfile )) {
667
+        } elseif( FALSE !== touch( $dirfile )) {
617 668
             /* new local file created */
618 669
           $this->filename = $value;
619 670
           return TRUE;
671
+        } else {
672
+                  return FALSE;
620 673
         }
621
-        else
622
-          return FALSE;
623 674
         break;
624 675
       case 'FORMAT':
625 676
         $value   = trim( $value );
@@ -627,8 +678,7 @@  discard block
 block discarded – undo
627 678
           $this->format             = 'xcal';
628 679
           $this->attributeDelimiter = $this->nl;
629 680
           $this->valueInit          = null;
630
-        }
631
-        else {
681
+        } else {
632 682
           $this->format             = null;
633 683
           $this->attributeDelimiter = ';';
634 684
           $this->valueInit          = ':';
@@ -667,13 +717,16 @@  discard block
 block discarded – undo
667 717
         return $this->setConfig( 'filename',  $parts['basename'] );
668 718
         break;
669 719
     }
670
-    if( !$res ) return FALSE;
720
+    if( !$res ) {
721
+        return FALSE;
722
+    }
671 723
     if( isset( $subcfg ) && !empty( $this->components )) {
672 724
       foreach( $subcfg as $cfgkey => $cfgvalue ) {
673 725
         foreach( $this->components as $cix => $component ) {
674 726
           $res = $component->setConfig( $cfgkey, $cfgvalue );
675
-          if( !$res )
676
-            break 2;
727
+          if( !$res ) {
728
+                      break 2;
729
+          }
677 730
           $this->components[$cix] = $component->copy(); // PHP4 compliant
678 731
         }
679 732
       }
@@ -708,27 +761,26 @@  discard block
 block discarded – undo
708 761
     if ( ctype_digit( (string) $arg1 )) {
709 762
       $argType = 'INDEX';
710 763
       $index   = (int) $arg1 - 1;
711
-    }
712
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
764
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
713 765
       $argType = strtolower( $arg1 );
714 766
       $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
715 767
     }
716 768
     $cix1dC = 0;
717 769
     foreach ( $this->components as $cix => $component) {
718
-      if( empty( $component )) continue;
770
+      if( empty( $component )) {
771
+          continue;
772
+      }
719 773
       unset( $component->propix );
720 774
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721 775
         unset( $this->components[$cix] );
722 776
         return TRUE;
723
-      }
724
-      elseif( $argType == $component->objName ) {
777
+      } elseif( $argType == $component->objName ) {
725 778
         if( $index == $cix1dC ) {
726 779
           unset( $this->components[$cix] );
727 780
           return TRUE;
728 781
         }
729 782
         $cix1dC++;
730
-      }
731
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
783
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732 784
         unset( $this->components[$cix] );
733 785
         return TRUE;
734 786
       }
@@ -750,37 +802,39 @@  discard block
 block discarded – undo
750 802
       $argType = 'INDEX';
751 803
       $index   = $this->compix['INDEX'] =
752 804
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
753
-    }
754
-    elseif ( ctype_digit( (string) $arg1 )) {
805
+    } elseif ( ctype_digit( (string) $arg1 )) {
755 806
       $argType = 'INDEX';
756 807
       $index   = (int) $arg1;
757 808
       unset( $this->compix );
758
-    }
759
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
809
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
760 810
       unset( $this->compix['INDEX'] );
761 811
       $argType = strtolower( $arg1 );
762
-      if( !$arg2 )
763
-        $index = $this->compix[$argType] =
812
+      if( !$arg2 ) {
813
+              $index = $this->compix[$argType] =
764 814
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
765
-      else
766
-        $index = (int) $arg2;
815
+      } else {
816
+              $index = (int) $arg2;
817
+      }
767 818
     }
768 819
     $index  -= 1;
769 820
     $ckeys =  array_keys( $this->components );
770
-    if( !empty( $index) && ( $index > end(  $ckeys )))
771
-      return FALSE;
821
+    if( !empty( $index) && ( $index > end(  $ckeys ))) {
822
+          return FALSE;
823
+    }
772 824
     $cix1gC = 0;
773 825
     foreach ( $this->components as $cix => $component) {
774
-      if( empty( $component )) continue;
826
+      if( empty( $component )) {
827
+          continue;
828
+      }
775 829
       unset( $component->propix );
776
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
777
-        return $component->copy();
778
-      elseif( $argType == $component->objName ) {
779
-         if( $index == $cix1gC )
780
-           return $component->copy();
830
+      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
831
+              return $component->copy();
832
+      } elseif( $argType == $component->objName ) {
833
+         if( $index == $cix1gC ) {
834
+                    return $component->copy();
835
+         }
781 836
          $cix1gC++;
782
-      }
783
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
837
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
784 838
         unset( $component->propix );
785 839
         return $component->copy();
786 840
       }
@@ -815,46 +869,68 @@  discard block
 block discarded – undo
815 869
  */
816 870
   function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
817 871
             /* check  if empty calendar */
818
-    if( 0 >= count( $this->components )) return FALSE;
872
+    if( 0 >= count( $this->components )) {
873
+        return FALSE;
874
+    }
819 875
             /* check default dates */
820
-    if( !$startY ) $startY = date( 'Y' );
821
-    if( !$startM ) $startM = date( 'm' );
822
-    if( !$startD ) $startD = date( 'd' );
876
+    if( !$startY ) {
877
+        $startY = date( 'Y' );
878
+    }
879
+    if( !$startM ) {
880
+        $startM = date( 'm' );
881
+    }
882
+    if( !$startD ) {
883
+        $startD = date( 'd' );
884
+    }
823 885
     $startDate = mktime( 0, 0, 0, $startM, $startD, $startY );
824
-    if( !$endY )   $endY   = $startY;
825
-    if( !$endM )   $endM   = $startM;
826
-    if( !$endD )   $endD   = $startD;
886
+    if( !$endY ) {
887
+        $endY   = $startY;
888
+    }
889
+    if( !$endM ) {
890
+        $endM   = $startM;
891
+    }
892
+    if( !$endD ) {
893
+        $endD   = $startD;
894
+    }
827 895
     $endDate   = mktime( 23, 59, 59, $endM, $endD, $endY );
828 896
             /* check component types */
829 897
     $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
830 898
     if( is_array( $cType )) {
831 899
       foreach( $cType as $cix => $theType ) {
832 900
         $cType[$cix] = $theType = strtolower( $theType );
833
-        if( !in_array( $theType, $validTypes ))
834
-          $cType[$cix] = 'vevent';
901
+        if( !in_array( $theType, $validTypes )) {
902
+                  $cType[$cix] = 'vevent';
903
+        }
835 904
       }
836 905
       $cType = array_unique( $cType );
837
-    }
838
-    elseif( !empty( $cType )) {
906
+    } elseif( !empty( $cType )) {
839 907
       $cType = strtolower( $cType );
840
-      if( !in_array( $cType, $validTypes ))
841
-        $cType = array( 'vevent' );
842
-      else
843
-        $cType = array( $cType );
844
-    }
845
-    else
846
-      $cType = $validTypes;
847
-    if( 0 >= count( $cType ))
848
-      $cType = $validTypes;
908
+      if( !in_array( $cType, $validTypes )) {
909
+              $cType = array( 'vevent' );
910
+      } else {
911
+              $cType = array( $cType );
912
+      }
913
+    } else {
914
+          $cType = $validTypes;
915
+    }
916
+    if( 0 >= count( $cType )) {
917
+          $cType = $validTypes;
918
+    }
849 919
             /* iterate components */
850 920
     $result = array();
851 921
     foreach ( $this->components as $cix => $component ) {
852
-      if( empty( $component )) continue;
922
+      if( empty( $component )) {
923
+          continue;
924
+      }
853 925
       unset( $component->propix, $start );
854 926
             /* deselect unvalid type components */
855
-      if( !in_array( $component->objName, $cType )) continue;
927
+      if( !in_array( $component->objName, $cType )) {
928
+          continue;
929
+      }
856 930
             /* deselect components without dtstart set */
857
-      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
931
+      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) {
932
+          continue;
933
+      }
858 934
       $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
859 935
       unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
860 936
       $startWdate = $component->_date2timestamp( $start );
@@ -888,8 +964,9 @@  discard block
 block discarded – undo
888 964
       }
889 965
       if( empty( $end )) {
890 966
         $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
891
-        if( !empty( $end ))
892
-          $durationExist = TRUE;
967
+        if( !empty( $end )) {
968
+                  $durationExist = TRUE;
969
+        }
893 970
    // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
894 971
       }
895 972
       if( empty( $end )) { // assume one day duration if missing end date
@@ -907,55 +984,75 @@  discard block
 block discarded – undo
907 984
       $exdatelist = array();
908 985
       $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
909 986
       $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
910
-      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
987
+      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) {
988
+          // check exrule
911 989
         $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
990
+      }
912 991
       while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
913 992
         foreach( $exdate as $theExdate ) {
914 993
           $exWdate = $component->_date2timestamp( $theExdate );
915
-          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
916
-            $exdatelist[$exWdate] = TRUE;
994
+          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) {
995
+                      $exdatelist[$exWdate] = TRUE;
996
+          }
917 997
         }
918 998
       }
919 999
             /* if 'any' components, check repeating components, removing all excluding dates */
920 1000
       if( TRUE === $any ) {
921 1001
             /* make a list of optional repeating dates for component occurence, rrule, rdate */
922 1002
         $recurlist = array();
923
-        while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
1003
+        while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) {
1004
+            // check rrule
924 1005
           $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
925
-        foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
926
-          $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
1006
+        }
1007
+        foreach( $recurlist as $recurkey => $recurvalue ) {
1008
+            // key=match date as timestamp
1009
+          $recurlist[$recurkey] = $rdurWsecs;
1010
+        }
1011
+        // add duration in seconds
927 1012
         while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
928 1013
           foreach( $rdate as $theRdate ) {
929 1014
             if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
930 1015
                    array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
931 1016
               $rstart = $component->_date2timestamp( $theRdate[0] );
932
-              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
933
-                continue;
934
-              if( isset( $theRdate[1]['year'] )) // date-date period
1017
+              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) {
1018
+                              continue;
1019
+              }
1020
+              if( isset( $theRdate[1]['year'] )) {
1021
+                  // date-date period
935 1022
                 $rend = $component->_date2timestamp( $theRdate[1] );
936
-              else {                             // date-duration period
1023
+              } else {                             // date-duration period
937 1024
                 $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
938 1025
                 $rend = $component->_date2timestamp( $rend );
939 1026
               }
940
-              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
941
-                $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
1027
+              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) {
1028
+                              $recurlist[$rstart] = ( $rstart - $rend );
1029
+              }
1030
+              // set start date + rdate duration in seconds
942 1031
             } // PERIOD end
943 1032
             else { // single date
944 1033
               $theRdate = $component->_date2timestamp( $theRdate );
945
-              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
946
-                $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
1034
+              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) {
1035
+                              $recurlist[$theRdate] = $rdurWsecs;
1036
+              }
1037
+              // set start date + event duration in seconds
947 1038
             }
948 1039
           }
949 1040
         }
950 1041
         if( 0 < count( $recurlist )) {
951 1042
           ksort( $recurlist );
952 1043
           foreach( $recurlist as $recurkey => $durvalue ) {
953
-            if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
1044
+            if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) {
1045
+                // not within period
954 1046
               continue;
955
-            if( isset( $exdatelist[$recurkey] )) // check excluded dates
1047
+            }
1048
+            if( isset( $exdatelist[$recurkey] )) {
1049
+                // check excluded dates
956 1050
               continue;
957
-            if( $startWdate >= $recurkey ) // exclude component start date
1051
+            }
1052
+            if( $startWdate >= $recurkey ) {
1053
+                // exclude component start date
958 1054
               continue;
1055
+            }
959 1056
             $component2   = $component->copy();
960 1057
             $rstart       = $component2->_timestamp2date( $recurkey, 6);
961 1058
             $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
@@ -965,16 +1062,16 @@  discard block
 block discarded – undo
965 1062
               $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
966 1063
             }
967 1064
             $datestring = date( $startDateFormat, strtotime( $datevalue ));
968
-            if( isset( $start['tz'] ))
969
-              $datestring .= ' '.$start['tz'];
1065
+            if( isset( $start['tz'] )) {
1066
+                          $datestring .= ' '.$start['tz'];
1067
+            }
970 1068
             $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
971 1069
             $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
972 1070
             if( $dtendExist || $dueExist ) {
973 1071
               if( $endAllDayEvent ) {
974 1072
                 $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
975 1073
                 $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
976
-              }
977
-              else {
1074
+              } else {
978 1075
                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
979 1076
                 if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) {
980 1077
                   $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
@@ -983,30 +1080,37 @@  discard block
 block discarded – undo
983 1080
                 }
984 1081
               }
985 1082
               $datestring = date( $endDateFormat, strtotime( $datevalue ));
986
-              if( isset( $end['tz'] ))
987
-                $datestring .= ' '.$end['tz'];
988
-              if( $dtendExist )
989
-                $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
990
-              elseif( $dueExist )
991
-                $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1083
+              if( isset( $end['tz'] )) {
1084
+                              $datestring .= ' '.$end['tz'];
1085
+              }
1086
+              if( $dtendExist ) {
1087
+                              $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
1088
+              } elseif( $dueExist ) {
1089
+                              $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1090
+              }
992 1091
             }
993 1092
             $rend   = $component2->_date2timestamp( $rend );
994 1093
             $rstart = $recurkey;
995 1094
             /* add repeating components within valid dates to output array, only start date */
996
-            if( $flat )
997
-              $result[] = $component2->copy(); // copy to output
1095
+            if( $flat ) {
1096
+                          $result[] = $component2->copy();
1097
+            }
1098
+            // copy to output
998 1099
             elseif( $split ) {
999
-              if( $rend > $endDate )
1000
-                $rend = $endDate;
1100
+              if( $rend > $endDate ) {
1101
+                              $rend = $endDate;
1102
+              }
1001 1103
               while( $rstart <= $rend ) { // iterate
1002 1104
                 $wd = getdate( $rstart );
1003 1105
                 if(( $rstart > $startDate ) &&      // date after dtstart
1004
-                    !isset( $exdatelist[$rstart] )) // check exclude date
1005
-                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1106
+                    !isset( $exdatelist[$rstart] )) {
1107
+                    // check exclude date
1108
+                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy();
1109
+                }
1110
+                // copy to output
1006 1111
                 $rstart += ( 24*60*60 ); // step one day
1007 1112
               }
1008
-            }
1009
-            elseif(( $rstart >= $startDate ) &&     // date within period
1113
+            } elseif(( $rstart >= $startDate ) &&     // date within period
1010 1114
                   !isset( $exdatelist[$rstart] )) { // check exclude date
1011 1115
               $wd = getdate( $rstart );
1012 1116
               $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
@@ -1014,19 +1118,29 @@  discard block
 block discarded – undo
1014 1118
           }
1015 1119
         }
1016 1120
             /* deselect components with startdate/enddate not within period */
1017
-        if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1121
+        if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) {
1122
+            continue;
1123
+        }
1018 1124
       }
1019 1125
             /* deselect components with startdate not within period */
1020
-      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1126
+      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) {
1127
+          continue;
1128
+      }
1021 1129
             /* add selected components within valid dates to output array */
1022
-      if( $flat )
1023
-        $result[] = $component->copy(); // copy to output;
1130
+      if( $flat ) {
1131
+              $result[] = $component->copy();
1132
+      }
1133
+      // copy to output;
1024 1134
       elseif( $split ) {
1025
-        if( $endWdate > $endDate )
1026
-          $endWdate = $endDate;     // use period end date
1135
+        if( $endWdate > $endDate ) {
1136
+                  $endWdate = $endDate;
1137
+        }
1138
+        // use period end date
1027 1139
         if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1028
-          if( $startWdate < $startDate )
1029
-            $startWdate = $startDate; // use period start date
1140
+          if( $startWdate < $startDate ) {
1141
+                      $startWdate = $startDate;
1142
+          }
1143
+          // use period start date
1030 1144
           while( $startWdate <= $endWdate ) { // iterate
1031 1145
             $wd = getdate( $startWdate );
1032 1146
             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
@@ -1040,8 +1154,9 @@  discard block
 block discarded – undo
1040 1154
         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041 1155
       }
1042 1156
     }
1043
-    if( 0 >= count( $result )) return FALSE;
1044
-    elseif( !$flat ) {
1157
+    if( 0 >= count( $result )) {
1158
+        return FALSE;
1159
+    } elseif( !$flat ) {
1045 1160
       foreach( $result as $y => $yeararr ) {
1046 1161
         foreach( $yeararr as $m => $montharr ) {
1047 1162
           ksort( $result[$y][$m] );
@@ -1063,8 +1178,9 @@  discard block
 block discarded – undo
1063 1178
  * @return void
1064 1179
  */
1065 1180
   function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066
-    if( '' >= $component->getConfig( 'language'))
1067
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
1181
+    if( '' >= $component->getConfig( 'language')) {
1182
+          $component->setConfig( 'language',  $this->getConfig( 'language' ));
1183
+    }
1068 1184
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1069 1185
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1070 1186
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1083,27 +1199,26 @@  discard block
 block discarded – undo
1083 1199
     if ( ctype_digit( (string) $arg1 )) {
1084 1200
       $argType = 'INDEX';
1085 1201
       $index   = (int) $arg1 - 1;
1086
-    }
1087
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1202
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1088 1203
       $argType = strtolower( $arg1 );
1089 1204
       $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1090 1205
     }
1091 1206
     $cix1sC = 0;
1092 1207
     foreach ( $this->components as $cix => $component2) {
1093
-      if( empty( $component2 )) continue;
1208
+      if( empty( $component2 )) {
1209
+          continue;
1210
+      }
1094 1211
       unset( $component2->propix );
1095 1212
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1096 1213
         $this->components[$cix] = $component->copy();
1097 1214
         return TRUE;
1098
-      }
1099
-      elseif( $argType == $component2->objName ) {
1215
+      } elseif( $argType == $component2->objName ) {
1100 1216
         if( $index == $cix1sC ) {
1101 1217
           $this->components[$cix] = $component->copy();
1102 1218
           return TRUE;
1103 1219
         }
1104 1220
         $cix1sC++;
1105
-      }
1106
-      elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1221
+      } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1107 1222
         $this->components[$cix] = $component->copy();
1108 1223
         return TRUE;
1109 1224
       }
@@ -1130,73 +1245,124 @@  discard block
 block discarded – undo
1130 1245
     }
1131 1246
   }
1132 1247
   function _cmpfcn( $a, $b ) {
1133
-    if( empty( $a ))                                   return -1;
1134
-    if( empty( $b ))                                   return  1;
1135
-    if(  'vtimezone' == $a->objName)                   return -1;
1136
-    if(  'vtimezone' == $b->objName)                   return  1;
1248
+    if( empty( $a )) {
1249
+        return -1;
1250
+    }
1251
+    if( empty( $b )) {
1252
+        return  1;
1253
+    }
1254
+    if(  'vtimezone' == $a->objName) {
1255
+        return -1;
1256
+    }
1257
+    if(  'vtimezone' == $b->objName) {
1258
+        return  1;
1259
+    }
1137 1260
     $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1138
-    if( empty( $astart ) && isset( $a->dtstart['value'] ))
1139
-      $astart = & $a->dtstart['value'];
1261
+    if( empty( $astart ) && isset( $a->dtstart['value'] )) {
1262
+          $astart = & $a->dtstart['value'];
1263
+    }
1140 1264
     $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1141
-    if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1142
-      $bstart = & $b->dtstart['value'];
1143
-    if(     empty( $astart ))                          return -1;
1144
-    elseif( empty( $bstart ))                          return  1;
1265
+    if( empty( $bstart ) && isset( $b->dtstart['value'] )) {
1266
+          $bstart = & $b->dtstart['value'];
1267
+    }
1268
+    if(     empty( $astart )) {
1269
+        return -1;
1270
+    } elseif( empty( $bstart )) {
1271
+        return  1;
1272
+    }
1145 1273
     foreach( $this->_sortkeys as $key ) {
1146
-      if    ( empty( $astart[$key] ))                  return -1;
1147
-      elseif( empty( $bstart[$key] ))                  return  1;
1148
-      if    (        $astart[$key] == $bstart[$key])   continue;
1149
-      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1150
-                                                       return -1;
1151
-      elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1152
-                                                       return  1;
1274
+      if    ( empty( $astart[$key] )) {
1275
+          return -1;
1276
+      } elseif( empty( $bstart[$key] )) {
1277
+          return  1;
1278
+      }
1279
+      if    (        $astart[$key] == $bstart[$key]) {
1280
+          continue;
1281
+      }
1282
+      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] )) {
1283
+                                                             return -1;
1284
+      } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) {
1285
+                                                             return  1;
1286
+      }
1153 1287
     }
1154 1288
     $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1155
-    if(     empty( $c ) && !empty( $a->dtend['value'] ))
1156
-      $c = & $a->dtend['value'];
1157
-    if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1158
-      $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1159
-    if(     empty( $c ) && !empty( $a->due['value'] ))
1160
-      $c = & $a->due['value'];
1161
-    if(     empty( $c ) && !empty( $a->duration['value'] ))
1162
-      $c = $a->duration2date();
1289
+    if(     empty( $c ) && !empty( $a->dtend['value'] )) {
1290
+          $c = & $a->dtend['value'];
1291
+    }
1292
+    if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) {
1293
+          $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1294
+    }
1295
+    if(     empty( $c ) && !empty( $a->due['value'] )) {
1296
+          $c = & $a->due['value'];
1297
+    }
1298
+    if(     empty( $c ) && !empty( $a->duration['value'] )) {
1299
+          $c = $a->duration2date();
1300
+    }
1163 1301
     $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1164
-    if(     empty( $d ) && !empty( $b->dtend['value'] ))
1165
-      $d = & $b->dtend['value'];
1166
-    if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1167
-      $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1168
-    if(     empty( $d ) && !empty( $b->due['value'] ))
1169
-      $d = & $b->due['value'];
1170
-    if(     empty( $d ) && !empty( $b->duration['value'] ))
1171
-      $d = $b->duration2date();
1172
-    if(     empty( $c ))                               return -1;
1173
-    elseif( empty( $d ))                               return  1;
1302
+    if(     empty( $d ) && !empty( $b->dtend['value'] )) {
1303
+          $d = & $b->dtend['value'];
1304
+    }
1305
+    if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) {
1306
+          $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1307
+    }
1308
+    if(     empty( $d ) && !empty( $b->due['value'] )) {
1309
+          $d = & $b->due['value'];
1310
+    }
1311
+    if(     empty( $d ) && !empty( $b->duration['value'] )) {
1312
+          $d = $b->duration2date();
1313
+    }
1314
+    if(     empty( $c )) {
1315
+        return -1;
1316
+    } elseif( empty( $d )) {
1317
+        return  1;
1318
+    }
1174 1319
     foreach( $this->_sortkeys as $key ) {
1175
-      if    ( !isset( $c[$key] ))                      return -1;
1176
-      elseif( !isset( $d[$key] ))                      return  1;
1177
-      if    (         $c[$key] == $d[$key] )           continue;
1178
-      if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1179
-      elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
1180
-    }
1181
-    if( isset( $a->created['value'] ))
1182
-     $e = & $a->created['value'];
1183
-    else
1184
-     $e = & $a->dtstamp['value'];
1185
-    if( isset( $b->created['value'] ))
1186
-      $f = & $b->created['value'];
1187
-    else
1188
-      $f = & $b->dtstamp['value'];
1320
+      if    ( !isset( $c[$key] )) {
1321
+          return -1;
1322
+      } elseif( !isset( $d[$key] )) {
1323
+          return  1;
1324
+      }
1325
+      if    (         $c[$key] == $d[$key] ) {
1326
+          continue;
1327
+      }
1328
+      if    ((  (int) $c[$key] ) < ((int) $d[$key])) {
1329
+          return -1;
1330
+      } elseif((  (int) $c[$key] ) > ((int) $d[$key])) {
1331
+          return  1;
1332
+      }
1333
+    }
1334
+    if( isset( $a->created['value'] )) {
1335
+         $e = & $a->created['value'];
1336
+    } else {
1337
+         $e = & $a->dtstamp['value'];
1338
+    }
1339
+    if( isset( $b->created['value'] )) {
1340
+          $f = & $b->created['value'];
1341
+    } else {
1342
+          $f = & $b->dtstamp['value'];
1343
+    }
1189 1344
     foreach( $this->_sortkeys as $key ) {
1190
-      if(       !isset( $e[$key] ))                    return -1;
1191
-      elseif(   !isset( $f[$key] ))                    return  1;
1192
-      if    (           $e[$key] == $f[$key] )         continue;
1193
-      if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1194
-      elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
1345
+      if(       !isset( $e[$key] )) {
1346
+          return -1;
1347
+      } elseif(   !isset( $f[$key] )) {
1348
+          return  1;
1349
+      }
1350
+      if    (           $e[$key] == $f[$key] ) {
1351
+          continue;
1352
+      }
1353
+      if    ((    (int) $e[$key] ) < ((int) $f[$key])) {
1354
+          return -1;
1355
+      } elseif((    (int) $e[$key] ) > ((int) $f[$key])) {
1356
+          return  1;
1357
+      }
1195 1358
     }
1196 1359
     if    ((            $a->uid['value'] ) <
1197
-           (            $b->uid['value'] ))            return -1;
1198
-    elseif((            $a->uid['value'] ) >
1199
-           (            $b->uid['value'] ))            return  1;
1360
+           (            $b->uid['value'] )) {
1361
+        return -1;
1362
+    } elseif((            $a->uid['value'] ) >
1363
+           (            $b->uid['value'] )) {
1364
+        return  1;
1365
+    }
1200 1366
     return 0;
1201 1367
   }
1202 1368
 /**
@@ -1211,42 +1377,57 @@  discard block
 block discarded – undo
1211 1377
   function parse( $filename=FALSE ) {
1212 1378
     if( !$filename ) {
1213 1379
             /* directory/filename previous set via setConfig directory+filename / url */
1214
-      if( FALSE === ( $filename = $this->getConfig( 'url' )))
1215
-        $filename = $this->getConfig( 'dirfile' );
1216
-    }
1217
-    elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1380
+      if( FALSE === ( $filename = $this->getConfig( 'url' ))) {
1381
+              $filename = $this->getConfig( 'dirfile' );
1382
+      }
1383
+    } elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1218 1384
            ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1219 1385
             /* remote file - URL */
1220 1386
       $this->setConfig( 'URL', $filename );
1221
-      if( !$filename = $this->getConfig( 'url' ))
1222
-        return FALSE;                 /* err 2 */
1223
-    }
1224
-    else {
1387
+      if( !$filename = $this->getConfig( 'url' )) {
1388
+              return FALSE;
1389
+      }
1390
+      /* err 2 */
1391
+    } else {
1225 1392
             /* local directory/filename */
1226 1393
       $parts = pathinfo( $filename );
1227 1394
       if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1228
-        if( !$this->setConfig( 'directory', $parts['dirname'] ))
1229
-          return FALSE;               /* err 3 */
1395
+        if( !$this->setConfig( 'directory', $parts['dirname'] )) {
1396
+                  return FALSE;
1397
+        }
1398
+        /* err 3 */
1399
+      }
1400
+      if( !$this->setConfig( 'filename', $parts['basename'] )) {
1401
+              return FALSE;
1230 1402
       }
1231
-      if( !$this->setConfig( 'filename', $parts['basename'] ))
1232
-        return FALSE;                 /* err 4 */
1403
+      /* err 4 */
1233 1404
     }
1234 1405
     if( 'http://' != substr( $filename, 0, 7 )) {
1235 1406
             /* local file error tests */
1236
-      if( !is_file( $filename ))      /* err 5 */
1407
+      if( !is_file( $filename )) {
1408
+          /* err 5 */
1237 1409
         return FALSE;
1238
-      if( !is_readable( $filename ))
1239
-        return FALSE;                 /* err 6 */
1240
-      if( !filesize( $filename ))
1241
-        return FALSE;                 /* err 7 */
1410
+      }
1411
+      if( !is_readable( $filename )) {
1412
+              return FALSE;
1413
+      }
1414
+      /* err 6 */
1415
+      if( !filesize( $filename )) {
1416
+              return FALSE;
1417
+      }
1418
+      /* err 7 */
1242 1419
       clearstatcache();
1243 1420
     }
1244 1421
             /* READ FILE */
1245
-    if( FALSE === ( $rows = file( $filename )))
1246
-      return FALSE;                   /* err 1 */
1422
+    if( FALSE === ( $rows = file( $filename ))) {
1423
+          return FALSE;
1424
+    }
1425
+    /* err 1 */
1247 1426
             /* identify BEGIN:VCALENDAR, MUST be first row */
1248
-    if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1249
-      return FALSE;                   /* err 8 */
1427
+    if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) {
1428
+          return FALSE;
1429
+    }
1430
+    /* err 8 */
1250 1431
             /* remove empty trailing lines */
1251 1432
     while( '' == trim( $rows[count( $rows ) - 1] )) {
1252 1433
       unset( $rows[count( $rows ) - 1] );
@@ -1256,34 +1437,37 @@  discard block
 block discarded – undo
1256 1437
     if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1257 1438
       return FALSE;                   /* err 9 */
1258 1439
     }
1259
-    if( 3 > count( $rows ))
1260
-      return FALSE;                   /* err 10 */
1440
+    if( 3 > count( $rows )) {
1441
+          return FALSE;
1442
+    }
1443
+    /* err 10 */
1261 1444
     $comp    = $subcomp = null;
1262 1445
     $actcomp = & $this;
1263 1446
     $nl      = $this->getConfig( 'nl' );
1264 1447
     $calsync = 0;
1265 1448
             /* identify components and update unparsed data within component */
1266 1449
     foreach( $rows as $line ) {
1267
-      if( '' == trim( $line ))
1268
-        continue;
1269
-      if( $nl == substr( $line, 0 - strlen( $nl )))
1270
-        $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1450
+      if( '' == trim( $line )) {
1451
+              continue;
1452
+      }
1453
+      if( $nl == substr( $line, 0 - strlen( $nl ))) {
1454
+              $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1455
+      }
1271 1456
       if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1272 1457
         $calsync++;
1273 1458
         continue;
1274
-      }
1275
-      elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1459
+      } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1276 1460
         $calsync--;
1277 1461
         continue;
1462
+      } elseif( 1 != $calsync ) {
1463
+              return FALSE;
1278 1464
       }
1279
-      elseif( 1 != $calsync )
1280
-        return FALSE;                 /* err 20 */
1465
+      /* err 20 */
1281 1466
       if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1282 1467
         if( null != $subcomp ) {
1283 1468
           $comp->setComponent( $subcomp );
1284 1469
           $subcomp = null;
1285
-        }
1286
-        else {
1470
+        } else {
1287 1471
           $this->setComponent( $comp );
1288 1472
           $comp = null;
1289 1473
         }
@@ -1294,17 +1478,18 @@  discard block
 block discarded – undo
1294 1478
         $line = str_replace( '\n', '', $line );
1295 1479
         $compname = trim (strtoupper( substr( $line, 6 )));
1296 1480
         if( null != $comp ) {
1297
-          if( 'VALARM' == $compname )
1298
-            $subcomp = new valarm();
1299
-          elseif( 'STANDARD' == $compname )
1300
-            $subcomp = new vtimezone( 'STANDARD' );
1301
-          elseif( 'DAYLIGHT' == $compname )
1302
-            $subcomp = new vtimezone( 'DAYLIGHT' );
1303
-          else
1304
-            return FALSE; /* err 6 */
1481
+          if( 'VALARM' == $compname ) {
1482
+                      $subcomp = new valarm();
1483
+          } elseif( 'STANDARD' == $compname ) {
1484
+                      $subcomp = new vtimezone( 'STANDARD' );
1485
+          } elseif( 'DAYLIGHT' == $compname ) {
1486
+                      $subcomp = new vtimezone( 'DAYLIGHT' );
1487
+          } else {
1488
+                      return FALSE;
1489
+          }
1490
+          /* err 6 */
1305 1491
           $actcomp = & $subcomp;
1306
-        }
1307
-        else {
1492
+        } else {
1308 1493
           switch( $compname ) {
1309 1494
             case 'VALARM':
1310 1495
               $comp = new valarm();
@@ -1353,8 +1538,7 @@  discard block
 block discarded – undo
1353 1538
           $newProp = FALSE;
1354 1539
           $lastix++;
1355 1540
           $proprows[$lastix]  = $line;
1356
-        }
1357
-        else {
1541
+        } else {
1358 1542
             /* remove line breaks */
1359 1543
           if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1360 1544
              (  ' ' == substr( $line, 0, 1 ))) {
@@ -1366,19 +1550,22 @@  discard block
 block discarded – undo
1366 1550
       }
1367 1551
       $toolbox = new calendarComponent();
1368 1552
       foreach( $proprows as $line ) {
1369
-        if( '\n' == substr( $line, -2 ))
1370
-          $line = substr( $line, 0, strlen( $line ) - 2 );
1553
+        if( '\n' == substr( $line, -2 )) {
1554
+                  $line = substr( $line, 0, strlen( $line ) - 2 );
1555
+        }
1371 1556
             /* get propname */
1372 1557
         $cix = $propname = null;
1373 1558
         for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1374
-          if( in_array( $line{$cix}, array( ':', ';' )))
1375
-            break;
1376
-          else
1377
-            $propname .= $line{$cix};
1559
+          if( in_array( $line{$cix}, array( ':', ';' ))) {
1560
+                      break;
1561
+          } else {
1562
+                      $propname .= $line{$cix};
1563
+          }
1378 1564
         }
1379 1565
             /* ignore version/prodid properties */
1380
-        if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1381
-          continue;
1566
+        if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) {
1567
+                  continue;
1568
+        }
1382 1569
         $line = substr( $line, $cix);
1383 1570
             /* separate attributes from value */
1384 1571
         $attr   = array();
@@ -1403,20 +1590,22 @@  discard block
 block discarded – undo
1403 1590
               break;
1404 1591
             }
1405 1592
           }
1406
-          if( ';' == $line{$cix} )
1407
-            $attr[++$attrix] = null;
1408
-          else
1409
-            $attr[$attrix] .= $line{$cix};
1593
+          if( ';' == $line{$cix} ) {
1594
+                      $attr[++$attrix] = null;
1595
+          } else {
1596
+                      $attr[$attrix] .= $line{$cix};
1597
+          }
1410 1598
         }
1411 1599
 
1412 1600
             /* make attributes in array format */
1413 1601
         $propattr = array();
1414 1602
         foreach( $attr as $attribute ) {
1415 1603
           $attrsplit = explode( '=', $attribute, 2 );
1416
-          if( 1 < count( $attrsplit ))
1417
-            $propattr[$attrsplit[0]] = $attrsplit[1];
1418
-          else
1419
-            $propattr[] = $attribute;
1604
+          if( 1 < count( $attrsplit )) {
1605
+                      $propattr[$attrsplit[0]] = $attrsplit[1];
1606
+          } else {
1607
+                      $propattr[] = $attribute;
1608
+          }
1420 1609
         }
1421 1610
             /* update Property */
1422 1611
         if( FALSE !== strpos( $line, ',' )) {
@@ -1430,13 +1619,14 @@  discard block
 block discarded – undo
1430 1619
             }
1431 1620
           }
1432 1621
           if( 1 < count( $content )) {
1433
-            foreach( $content as $cix => $contentPart )
1434
-              $content[$cix] = $toolbox->_strunrep( $contentPart );
1622
+            foreach( $content as $cix => $contentPart ) {
1623
+                          $content[$cix] = $toolbox->_strunrep( $contentPart );
1624
+            }
1435 1625
             $this->setProperty( $propname, $content, $propattr );
1436 1626
             continue;
1627
+          } else {
1628
+                      $line = reset( $content );
1437 1629
           }
1438
-          else
1439
-            $line = reset( $content );
1440 1630
           $line = $toolbox->_strunrep( $line );
1441 1631
         }
1442 1632
         $this->setProperty( $propname, trim( $line ), $propattr );
@@ -1445,12 +1635,14 @@  discard block
 block discarded – undo
1445 1635
             /* parse Components */
1446 1636
     if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1447 1637
       for( $six = 0; $six < count( $this->components ); $six++ ) {
1448
-        if( !empty( $this->components[$six] ))
1449
-          $this->components[$six]->parse();
1638
+        if( !empty( $this->components[$six] )) {
1639
+                  $this->components[$six]->parse();
1640
+        }
1450 1641
       }
1642
+    } else {
1643
+          return FALSE;
1451 1644
     }
1452
-    else
1453
-      return FALSE;                   /* err 91 or something.. . */
1645
+    /* err 91 or something.. . */
1454 1646
     return TRUE;
1455 1647
   }
1456 1648
 /*********************************************************************************/
@@ -1482,8 +1674,9 @@  discard block
 block discarded – undo
1482 1674
     switch( $this->format ) {
1483 1675
       case 'xcal':
1484 1676
         $nlstrlen = strlen( $this->nl );
1485
-        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1486
-          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1677
+        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) {
1678
+                  $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1679
+        }
1487 1680
         $calendarStart .= '>'.$this->nl;
1488 1681
         break;
1489 1682
       default:
@@ -1491,9 +1684,12 @@  discard block
 block discarded – undo
1491 1684
     }
1492 1685
     $calendar .= $this->createXprop();
1493 1686
     foreach( $this->components as $component ) {
1494
-      if( empty( $component )) continue;
1495
-      if( '' >= $component->getConfig( 'language'))
1496
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
1687
+      if( empty( $component )) {
1688
+          continue;
1689
+      }
1690
+      if( '' >= $component->getConfig( 'language')) {
1691
+              $component->setConfig( 'language',  $this->getConfig( 'language' ));
1692
+      }
1497 1693
       $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1498 1694
       $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1499 1695
       $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1506,8 +1702,10 @@  discard block
 block discarded – undo
1506 1702
       foreach( $this->xcaldecl as $declix => $declPart ) {
1507 1703
         if(( 0 < count( $old_xcaldecl)) &&
1508 1704
            ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1509
-           ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1510
-          continue; // no duplicate uri and ext. references
1705
+           ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) {
1706
+                  continue;
1707
+        }
1708
+        // no duplicate uri and ext. references
1511 1709
         $calendarxCaldecl .= '<!';
1512 1710
         foreach( $declPart as $declKey => $declValue ) {
1513 1711
           switch( $declKey ) {                    // index
@@ -1560,10 +1758,11 @@  discard block
 block discarded – undo
1560 1758
     $filesize = strlen( $output );
1561 1759
 //    if( headers_sent( $filename, $linenum ))
1562 1760
 //      die( "Headers already sent in $filename on line $linenum\n" );
1563
-    if( 'xcal' == $this->format )
1564
-      header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1565
-    else
1566
-      header( 'Content-Type: text/calendar; charset=utf-8' );
1761
+    if( 'xcal' == $this->format ) {
1762
+          header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1763
+    } else {
1764
+          header( 'Content-Type: text/calendar; charset=utf-8' );
1765
+    }
1567 1766
     header( 'Content-Length: '.$filesize );
1568 1767
     header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1569 1768
     header( 'Cache-Control: max-age=10' );
@@ -1581,23 +1780,28 @@  discard block
 block discarded – undo
1581 1780
  * @return bool
1582 1781
  */
1583 1782
   function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1584
-    if( $directory )
1585
-      $this->setConfig( 'directory', $directory );
1586
-    if( $filename )
1587
-      $this->setConfig( 'filename',  $filename );
1588
-    if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1589
-      $this->setConfig( 'delimiter', $delimiter );
1590
-    if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1591
-      $dirfile = $this->getConfig( 'dirfile' );
1783
+    if( $directory ) {
1784
+          $this->setConfig( 'directory', $directory );
1785
+    }
1786
+    if( $filename ) {
1787
+          $this->setConfig( 'filename',  $filename );
1788
+    }
1789
+    if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) {
1790
+          $this->setConfig( 'delimiter', $delimiter );
1791
+    }
1792
+    if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) {
1793
+          $dirfile = $this->getConfig( 'dirfile' );
1794
+    }
1592 1795
     $iCalFile = @fopen( $dirfile, 'w' );
1593 1796
     if( $iCalFile ) {
1594
-      if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1595
-        return FALSE;
1797
+      if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) {
1798
+              return FALSE;
1799
+      }
1596 1800
       fclose( $iCalFile );
1597 1801
       return TRUE;
1802
+    } else {
1803
+          return FALSE;
1598 1804
     }
1599
-    else
1600
-      return FALSE;
1601 1805
   }
1602 1806
 /**
1603 1807
  * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
@@ -1616,15 +1820,19 @@  discard block
 block discarded – undo
1616 1820
       $timeout   = (int) $directory;
1617 1821
       $directory = FALSE;
1618 1822
     }
1619
-    if( $directory )
1620
-      $this->setConfig( 'directory', $directory );
1621
-    if( $filename )
1622
-      $this->setConfig( 'filename',  $filename );
1623
-    if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1624
-      $this->setConfig( 'delimiter', $delimiter );
1823
+    if( $directory ) {
1824
+          $this->setConfig( 'directory', $directory );
1825
+    }
1826
+    if( $filename ) {
1827
+          $this->setConfig( 'filename',  $filename );
1828
+    }
1829
+    if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) {
1830
+          $this->setConfig( 'delimiter', $delimiter );
1831
+    }
1625 1832
     $filesize    = $this->getConfig( 'filesize' );
1626
-    if( 0 >= $filesize )
1627
-      return FALSE;
1833
+    if( 0 >= $filesize ) {
1834
+          return FALSE;
1835
+    }
1628 1836
     $dirfile     = $this->getConfig( 'dirfile' );
1629 1837
     if( time() - filemtime( $dirfile ) < $timeout) {
1630 1838
       clearstatcache();
@@ -1632,10 +1840,11 @@  discard block
 block discarded – undo
1632 1840
       $filename  = $this->getConfig( 'filename' );
1633 1841
 //    if( headers_sent( $filename, $linenum ))
1634 1842
 //      die( "Headers already sent in $filename on line $linenum\n" );
1635
-      if( 'xcal' == $this->format )
1636
-        header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1637
-      else
1638
-        header( 'Content-Type: text/calendar; charset=utf-8' );
1843
+      if( 'xcal' == $this->format ) {
1844
+              header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1845
+      } else {
1846
+              header( 'Content-Type: text/calendar; charset=utf-8' );
1847
+      }
1639 1848
       header( 'Content-Length: '.$filesize );
1640 1849
       header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1641 1850
       header( 'Cache-Control: max-age=10' );
@@ -1645,9 +1854,9 @@  discard block
 block discarded – undo
1645 1854
         fclose( $fp );
1646 1855
       }
1647 1856
       die();
1857
+    } else {
1858
+          return FALSE;
1648 1859
     }
1649
-    else
1650
-      return FALSE;
1651 1860
   }
1652 1861
 }
1653 1862
 /*********************************************************************************/
@@ -1718,9 +1927,12 @@  discard block
 block discarded – undo
1718 1927
  * @return string
1719 1928
  */
1720 1929
   function createAction() {
1721
-    if( empty( $this->action )) return FALSE;
1722
-    if( empty( $this->action['value'] ))
1723
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1930
+    if( empty( $this->action )) {
1931
+        return FALSE;
1932
+    }
1933
+    if( empty( $this->action['value'] )) {
1934
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1935
+    }
1724 1936
     $attributes = $this->_createParams( $this->action['params'] );
1725 1937
     return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1726 1938
   }
@@ -1734,7 +1946,11 @@  discard block
 block discarded – undo
1734 1946
  * @return bool
1735 1947
  */
1736 1948
   function setAction( $value, $params=FALSE ) {
1737
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1949
+    if( empty( $value )) {
1950
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
1951
+    } else {
1952
+        return FALSE;
1953
+    }
1738 1954
     $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1739 1955
     return TRUE;
1740 1956
   }
@@ -1750,14 +1966,17 @@  discard block
 block discarded – undo
1750 1966
  * @return string
1751 1967
  */
1752 1968
   function createAttach() {
1753
-    if( empty( $this->attach )) return FALSE;
1969
+    if( empty( $this->attach )) {
1970
+        return FALSE;
1971
+    }
1754 1972
     $output       = null;
1755 1973
     foreach( $this->attach as $attachPart ) {
1756 1974
       if(! empty( $attachPart['value'] )) {
1757 1975
         $attributes = $this->_createParams( $attachPart['params'] );
1758 1976
         $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1977
+      } elseif( $this->getConfig( 'allowEmpty' )) {
1978
+          $output .= $this->_createElement( 'ATTACH' );
1759 1979
       }
1760
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1761 1980
     }
1762 1981
     return $output;
1763 1982
   }
@@ -1772,7 +1991,11 @@  discard block
 block discarded – undo
1772 1991
  * @return bool
1773 1992
  */
1774 1993
   function setAttach( $value, $params=FALSE, $index=FALSE ) {
1775
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1994
+    if( empty( $value )) {
1995
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
1996
+    } else {
1997
+        return FALSE;
1998
+    }
1776 1999
     $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1777 2000
     return TRUE;
1778 2001
   }
@@ -1788,19 +2011,22 @@  discard block
 block discarded – undo
1788 2011
  * @return string
1789 2012
  */
1790 2013
   function createAttendee() {
1791
-    if( empty( $this->attendee )) return FALSE;
2014
+    if( empty( $this->attendee )) {
2015
+        return FALSE;
2016
+    }
1792 2017
     $output = null;
1793 2018
     foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1794 2019
       if( empty( $attendeePart['value'] )) {
1795
-        if( $this->getConfig( 'allowEmpty' ))
1796
-          $output .= $this->_createElement( 'ATTENDEE' );
2020
+        if( $this->getConfig( 'allowEmpty' )) {
2021
+                  $output .= $this->_createElement( 'ATTENDEE' );
2022
+        }
1797 2023
         continue;
1798 2024
       }
1799 2025
       $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1800 2026
       foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1801
-        if( 'value' == $paramlabel )
1802
-          $attendee2  .= 'MAILTO:'.$paramvalue;
1803
-        elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
2027
+        if( 'value' == $paramlabel ) {
2028
+                  $attendee2  .= 'MAILTO:'.$paramvalue;
2029
+        } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1804 2030
           foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1805 2031
             $attendee11 = $attendee12 = null;
1806 2032
             if( is_int( $optparamlabel )) {
@@ -1860,7 +2086,11 @@  discard block
 block discarded – undo
1860 2086
  * @return bool
1861 2087
  */
1862 2088
   function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1863
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2089
+    if( empty( $value )) {
2090
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2091
+    } else {
2092
+        return FALSE;
2093
+    }
1864 2094
     $value = str_replace ( 'MAILTO:', '', $value );
1865 2095
     $value = str_replace ( 'mailto:', '', $value );
1866 2096
     $params2 = array();
@@ -1876,16 +2106,17 @@  discard block
 block discarded – undo
1876 2106
               foreach( $optparamvalue as $part ) {
1877 2107
                 $part = str_replace( 'MAILTO:', '', $part );
1878 2108
                 $part = str_replace( 'mailto:', '', $part );
1879
-                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1880
-                  $part = substr( $part, 1, ( strlen($part)-2 ));
2109
+                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2110
+                                  $part = substr( $part, 1, ( strlen($part)-2 ));
2111
+                }
1881 2112
                 $optarrays[$optparamlabel][] = $part;
1882 2113
               }
1883
-            }
1884
-            else {
2114
+            } else {
1885 2115
               $part = str_replace( 'MAILTO:', '', $optparamvalue );
1886 2116
               $part = str_replace( 'mailto:', '', $part );
1887
-              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1888
-                $part = substr( $part, 1, ( strlen($part)-2 ));
2117
+              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2118
+                              $part = substr( $part, 1, ( strlen($part)-2 ));
2119
+              }
1889 2120
               $optarrays[$optparamlabel][] = $part;
1890 2121
             }
1891 2122
             break;
@@ -1895,14 +2126,16 @@  discard block
 block discarded – undo
1895 2126
               $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1896 2127
             }
1897 2128
             if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1898
-               ( '"' == substr( $optparamvalue, -1 )))
1899
-              $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2129
+               ( '"' == substr( $optparamvalue, -1 ))) {
2130
+                          $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2131
+            }
1900 2132
             $params2[$optparamlabel] = $optparamvalue;
1901 2133
             break;
1902 2134
         } // end switch( $optparamlabel.. .
1903 2135
       } // end foreach( $optparam.. .
1904
-      foreach( $optarrays as $optparamlabel => $optparams )
1905
-        $params2[$optparamlabel] = $optparams;
2136
+      foreach( $optarrays as $optparamlabel => $optparams ) {
2137
+              $params2[$optparamlabel] = $optparams;
2138
+      }
1906 2139
     }
1907 2140
         // remove defaults
1908 2141
     $this->_existRem( $params2, 'CUTYPE',   'INDIVIDUAL' );
@@ -1912,8 +2145,9 @@  discard block
 block discarded – undo
1912 2145
         // check language setting
1913 2146
     if( isset( $params2['CN' ] )) {
1914 2147
       $lang = $this->getConfig( 'language' );
1915
-      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1916
-        $params2['LANGUAGE' ] = $lang;
2148
+      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) {
2149
+              $params2['LANGUAGE' ] = $lang;
2150
+      }
1917 2151
     }
1918 2152
     $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1919 2153
     return TRUE;
@@ -1930,22 +2164,26 @@  discard block
 block discarded – undo
1930 2164
  * @return string
1931 2165
  */
1932 2166
   function createCategories() {
1933
-    if( empty( $this->categories )) return FALSE;
2167
+    if( empty( $this->categories )) {
2168
+        return FALSE;
2169
+    }
1934 2170
     $output = null;
1935 2171
     foreach( $this->categories as $category ) {
1936 2172
       if( empty( $category['value'] )) {
1937
-        if ( $this->getConfig( 'allowEmpty' ))
1938
-          $output .= $this->_createElement( 'CATEGORIES' );
2173
+        if ( $this->getConfig( 'allowEmpty' )) {
2174
+                  $output .= $this->_createElement( 'CATEGORIES' );
2175
+        }
1939 2176
         continue;
1940 2177
       }
1941 2178
       $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1942 2179
       if( is_array( $category['value'] )) {
1943
-        foreach( $category['value'] as $cix => $categoryPart )
1944
-          $category['value'][$cix] = $this->_strrep( $categoryPart );
2180
+        foreach( $category['value'] as $cix => $categoryPart ) {
2181
+                  $category['value'][$cix] = $this->_strrep( $categoryPart );
2182
+        }
1945 2183
         $content  = implode( ',', $category['value'] );
2184
+      } else {
2185
+              $content  = $this->_strrep( $category['value'] );
1946 2186
       }
1947
-      else
1948
-        $content  = $this->_strrep( $category['value'] );
1949 2187
       $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1950 2188
     }
1951 2189
     return $output;
@@ -1961,7 +2199,11 @@  discard block
 block discarded – undo
1961 2199
  * @return bool
1962 2200
  */
1963 2201
   function setCategories( $value, $params=FALSE, $index=FALSE ) {
1964
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2202
+    if( empty( $value )) {
2203
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2204
+    } else {
2205
+        return FALSE;
2206
+    }
1965 2207
     $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1966 2208
     return TRUE;
1967 2209
  }
@@ -1977,9 +2219,12 @@  discard block
 block discarded – undo
1977 2219
  * @return string
1978 2220
  */
1979 2221
   function createClass() {
1980
-    if( empty( $this->class )) return FALSE;
1981
-    if( empty( $this->class['value'] ))
1982
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2222
+    if( empty( $this->class )) {
2223
+        return FALSE;
2224
+    }
2225
+    if( empty( $this->class['value'] )) {
2226
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2227
+    }
1983 2228
     $attributes = $this->_createParams( $this->class['params'] );
1984 2229
     return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1985 2230
   }
@@ -1993,7 +2238,11 @@  discard block
 block discarded – undo
1993 2238
  * @return bool
1994 2239
  */
1995 2240
   function setClass( $value, $params=FALSE ) {
1996
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2241
+    if( empty( $value )) {
2242
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2243
+    } else {
2244
+        return FALSE;
2245
+    }
1997 2246
     $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1998 2247
     return TRUE;
1999 2248
   }
@@ -2009,11 +2258,15 @@  discard block
 block discarded – undo
2009 2258
  * @return string
2010 2259
  */
2011 2260
   function createComment() {
2012
-    if( empty( $this->comment )) return FALSE;
2013
-    $output = null;
2261
+    if( empty( $this->comment )) {
2262
+        return FALSE;
2263
+    }
2264
+    $output = null;
2014 2265
     foreach( $this->comment as $commentPart ) {
2015 2266
       if( empty( $commentPart['value'] )) {
2016
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2267
+        if( $this->getConfig( 'allowEmpty' )) {
2268
+            $output .= $this->_createElement( 'COMMENT' );
2269
+        }
2017 2270
         continue;
2018 2271
       }
2019 2272
       $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
@@ -2033,7 +2286,11 @@  discard block
 block discarded – undo
2033 2286
  * @return bool
2034 2287
  */
2035 2288
   function setComment( $value, $params=FALSE, $index=FALSE ) {
2036
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2289
+    if( empty( $value )) {
2290
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2291
+    } else {
2292
+        return FALSE;
2293
+    }
2037 2294
     $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2038 2295
     return TRUE;
2039 2296
   }
@@ -2049,16 +2306,20 @@  discard block
 block discarded – undo
2049 2306
  * @return string
2050 2307
  */
2051 2308
   function createCompleted( ) {
2052
-    if( empty( $this->completed )) return FALSE;
2309
+    if( empty( $this->completed )) {
2310
+        return FALSE;
2311
+    }
2053 2312
     if( !isset( $this->completed['value']['year'] )  &&
2054 2313
         !isset( $this->completed['value']['month'] ) &&
2055 2314
         !isset( $this->completed['value']['day'] )   &&
2056 2315
         !isset( $this->completed['value']['hour'] )  &&
2057 2316
         !isset( $this->completed['value']['min'] )   &&
2058
-        !isset( $this->completed['value']['sec'] ))
2059
-      if( $this->getConfig( 'allowEmpty' ))
2317
+        !isset( $this->completed['value']['sec'] )) {
2318
+          if( $this->getConfig( 'allowEmpty' ))
2060 2319
         return $this->_createElement( 'COMPLETED' );
2061
-      else return FALSE;
2320
+    } else {
2321
+          return FALSE;
2322
+      }
2062 2323
     $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2063 2324
     $attributes = $this->_createParams( $this->completed['params'] );
2064 2325
     return $this->_createElement( 'COMPLETED', $attributes, $formatted );
@@ -2082,9 +2343,9 @@  discard block
 block discarded – undo
2082 2343
       if( $this->getConfig( 'allowEmpty' )) {
2083 2344
         $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2084 2345
         return TRUE;
2346
+      } else {
2347
+              return FALSE;
2085 2348
       }
2086
-      else
2087
-        return FALSE;
2088 2349
     }
2089 2350
     $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2090 2351
     return TRUE;
@@ -2101,15 +2362,18 @@  discard block
 block discarded – undo
2101 2362
  * @return string
2102 2363
  */
2103 2364
   function createContact() {
2104
-    if( empty( $this->contact )) return FALSE;
2365
+    if( empty( $this->contact )) {
2366
+        return FALSE;
2367
+    }
2105 2368
     $output = null;
2106 2369
     foreach( $this->contact as $contact ) {
2107 2370
       if( !empty( $contact['value'] )) {
2108 2371
         $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2109 2372
         $content    = $this->_strrep( $contact['value'] );
2110 2373
         $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2374
+      } elseif( $this->getConfig( 'allowEmpty' )) {
2375
+          $output .= $this->_createElement( 'CONTACT' );
2111 2376
       }
2112
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2113 2377
     }
2114 2378
     return $output;
2115 2379
   }
@@ -2124,7 +2388,11 @@  discard block
 block discarded – undo
2124 2388
  * @return bool
2125 2389
  */
2126 2390
   function setContact( $value, $params=FALSE, $index=FALSE ) {
2127
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2391
+    if( empty( $value )) {
2392
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2393
+    } else {
2394
+        return FALSE;
2395
+    }
2128 2396
     $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2129 2397
     return TRUE;
2130 2398
   }
@@ -2140,7 +2408,9 @@  discard block
 block discarded – undo
2140 2408
  * @return string
2141 2409
  */
2142 2410
   function createCreated() {
2143
-    if( empty( $this->created )) return FALSE;
2411
+    if( empty( $this->created )) {
2412
+        return FALSE;
2413
+    }
2144 2414
     $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2145 2415
     $attributes = $this->_createParams( $this->created['params'] );
2146 2416
     return $this->_createElement( 'CREATED', $attributes, $formatted );
@@ -2178,15 +2448,18 @@  discard block
 block discarded – undo
2178 2448
  * @return string
2179 2449
  */
2180 2450
   function createDescription() {
2181
-    if( empty( $this->description )) return FALSE;
2451
+    if( empty( $this->description )) {
2452
+        return FALSE;
2453
+    }
2182 2454
     $output       = null;
2183 2455
     foreach( $this->description as $description ) {
2184 2456
       if( !empty( $description['value'] )) {
2185 2457
         $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2186 2458
         $content    = $this->_strrep( $description['value'] );
2187 2459
         $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2460
+      } elseif( $this->getConfig( 'allowEmpty' )) {
2461
+          $output .= $this->_createElement( 'DESCRIPTION' );
2188 2462
       }
2189
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2190 2463
     }
2191 2464
     return $output;
2192 2465
   }
@@ -2201,7 +2474,12 @@  discard block
 block discarded – undo
2201 2474
  * @return bool
2202 2475
  */
2203 2476
   function setDescription( $value, $params=FALSE, $index=FALSE ) {
2204
-    if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2477
+    if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) {
2478
+        $value = null;
2479
+    } else {
2480
+        return FALSE;
2481
+    }
2482
+    }
2205 2483
     $this->_setMval( $this->description, $value, $params, FALSE, $index );
2206 2484
     return TRUE;
2207 2485
   }
@@ -2217,16 +2495,20 @@  discard block
 block discarded – undo
2217 2495
  * @return string
2218 2496
  */
2219 2497
   function createDtend() {
2220
-    if( empty( $this->dtend )) return FALSE;
2498
+    if( empty( $this->dtend )) {
2499
+        return FALSE;
2500
+    }
2221 2501
     if( !isset( $this->dtend['value']['year'] )  &&
2222 2502
         !isset( $this->dtend['value']['month'] ) &&
2223 2503
         !isset( $this->dtend['value']['day'] )   &&
2224 2504
         !isset( $this->dtend['value']['hour'] )  &&
2225 2505
         !isset( $this->dtend['value']['min'] )   &&
2226
-        !isset( $this->dtend['value']['sec'] ))
2227
-      if( $this->getConfig( 'allowEmpty' ))
2506
+        !isset( $this->dtend['value']['sec'] )) {
2507
+          if( $this->getConfig( 'allowEmpty' ))
2228 2508
         return $this->_createElement( 'DTEND' );
2229
-      else return FALSE;
2509
+    } else {
2510
+          return FALSE;
2511
+      }
2230 2512
     $formatted  = $this->_format_date_time( $this->dtend['value'] );
2231 2513
     $attributes = $this->_createParams( $this->dtend['params'] );
2232 2514
     return $this->_createElement( 'DTEND', $attributes, $formatted );
@@ -2251,9 +2533,9 @@  discard block
 block discarded – undo
2251 2533
       if( $this->getConfig( 'allowEmpty' )) {
2252 2534
         $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2253 2535
         return TRUE;
2536
+      } else {
2537
+              return FALSE;
2254 2538
       }
2255
-      else
2256
-        return FALSE;
2257 2539
     }
2258 2540
     $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2259 2541
     return TRUE;
@@ -2275,8 +2557,9 @@  discard block
 block discarded – undo
2275 2557
         !isset( $this->dtstamp['value']['day'] )   &&
2276 2558
         !isset( $this->dtstamp['value']['hour'] )  &&
2277 2559
         !isset( $this->dtstamp['value']['min'] )   &&
2278
-        !isset( $this->dtstamp['value']['sec'] ))
2279
-      $this->_makeDtstamp();
2560
+        !isset( $this->dtstamp['value']['sec'] )) {
2561
+          $this->_makeDtstamp();
2562
+    }
2280 2563
     $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2281 2564
     $attributes = $this->_createParams( $this->dtstamp['params'] );
2282 2565
     return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
@@ -2312,10 +2595,11 @@  discard block
 block discarded – undo
2312 2595
  * @return TRUE
2313 2596
  */
2314 2597
   function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315
-    if( empty( $year ))
2316
-      $this->_makeDtstamp();
2317
-    else
2318
-      $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2598
+    if( empty( $year )) {
2599
+          $this->_makeDtstamp();
2600
+    } else {
2601
+          $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2602
+    }
2319 2603
     return TRUE;
2320 2604
   }
2321 2605
 /*********************************************************************************/
@@ -2330,18 +2614,23 @@  discard block
 block discarded – undo
2330 2614
  * @return string
2331 2615
  */
2332 2616
   function createDtstart() {
2333
-    if( empty( $this->dtstart )) return FALSE;
2617
+    if( empty( $this->dtstart )) {
2618
+        return FALSE;
2619
+    }
2334 2620
     if( !isset( $this->dtstart['value']['year'] )  &&
2335 2621
         !isset( $this->dtstart['value']['month'] ) &&
2336 2622
         !isset( $this->dtstart['value']['day'] )   &&
2337 2623
         !isset( $this->dtstart['value']['hour'] )  &&
2338 2624
         !isset( $this->dtstart['value']['min'] )   &&
2339
-        !isset( $this->dtstart['value']['sec'] ))
2340
-    if( $this->getConfig( 'allowEmpty' ))
2625
+        !isset( $this->dtstart['value']['sec'] )) {
2626
+        if( $this->getConfig( 'allowEmpty' ))
2341 2627
       return $this->_createElement( 'DTSTART' );
2342
-    else return FALSE;
2343
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2344
-      unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2628
+    } else {
2629
+        return FALSE;
2630
+    }
2631
+    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
2632
+          unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2633
+    }
2345 2634
     $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2346 2635
     $attributes = $this->_createParams( $this->dtstart['params'] );
2347 2636
     return $this->_createElement( 'DTSTART', $attributes, $formatted );
@@ -2366,9 +2655,9 @@  discard block
 block discarded – undo
2366 2655
       if( $this->getConfig( 'allowEmpty' )) {
2367 2656
         $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2368 2657
         return TRUE;
2658
+      } else {
2659
+              return FALSE;
2369 2660
       }
2370
-      else
2371
-        return FALSE;
2372 2661
     }
2373 2662
     $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2374 2663
     return TRUE;
@@ -2385,16 +2674,20 @@  discard block
 block discarded – undo
2385 2674
  * @return string
2386 2675
  */
2387 2676
   function createDue() {
2388
-    if( empty( $this->due )) return FALSE;
2677
+    if( empty( $this->due )) {
2678
+        return FALSE;
2679
+    }
2389 2680
     if( !isset( $this->due['value']['year'] )  &&
2390 2681
         !isset( $this->due['value']['month'] ) &&
2391 2682
         !isset( $this->due['value']['day'] )   &&
2392 2683
         !isset( $this->due['value']['hour'] )  &&
2393 2684
         !isset( $this->due['value']['min'] )   &&
2394
-        !isset( $this->due['value']['sec'] ))
2395
-      if( $this->getConfig( 'allowEmpty' ))
2685
+        !isset( $this->due['value']['sec'] )) {
2686
+          if( $this->getConfig( 'allowEmpty' ))
2396 2687
         return $this->_createElement( 'DUE' );
2397
-      else return FALSE;
2688
+    } else {
2689
+          return FALSE;
2690
+      }
2398 2691
     $formatted  = $this->_format_date_time( $this->due['value'] );
2399 2692
     $attributes = $this->_createParams( $this->due['params'] );
2400 2693
     return $this->_createElement( 'DUE', $attributes, $formatted );
@@ -2418,9 +2711,9 @@  discard block
 block discarded – undo
2418 2711
       if( $this->getConfig( 'allowEmpty' )) {
2419 2712
         $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2420 2713
         return TRUE;
2714
+      } else {
2715
+              return FALSE;
2421 2716
       }
2422
-      else
2423
-        return FALSE;
2424 2717
     }
2425 2718
     $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2426 2719
     return TRUE;
@@ -2437,15 +2730,19 @@  discard block
 block discarded – undo
2437 2730
  * @return string
2438 2731
  */
2439 2732
   function createDuration() {
2440
-    if( empty( $this->duration )) return FALSE;
2733
+    if( empty( $this->duration )) {
2734
+        return FALSE;
2735
+    }
2441 2736
     if( !isset( $this->duration['value']['week'] ) &&
2442 2737
         !isset( $this->duration['value']['day'] )  &&
2443 2738
         !isset( $this->duration['value']['hour'] ) &&
2444 2739
         !isset( $this->duration['value']['min'] )  &&
2445
-        !isset( $this->duration['value']['sec'] ))
2446
-      if( $this->getConfig( 'allowEmpty' ))
2740
+        !isset( $this->duration['value']['sec'] )) {
2741
+          if( $this->getConfig( 'allowEmpty' ))
2447 2742
         return $this->_createElement( 'DURATION', array(), null );
2448
-      else return FALSE;
2743
+    } else {
2744
+          return FALSE;
2745
+      }
2449 2746
     $attributes = $this->_createParams( $this->duration['params'] );
2450 2747
     return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2451 2748
   }
@@ -2463,19 +2760,24 @@  discard block
 block discarded – undo
2463 2760
  * @return bool
2464 2761
  */
2465 2762
   function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2466
-    if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2467
-    if( is_array( $week ) && ( 1 <= count( $week )))
2468
-      $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2469
-    elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2763
+    if( empty( $week )) {
2764
+        if( $this->getConfig( 'allowEmpty' )) $week = null;
2765
+    } else {
2766
+        return FALSE;
2767
+    }
2768
+    if( is_array( $week ) && ( 1 <= count( $week ))) {
2769
+          $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2770
+    } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2470 2771
       $week = trim( $week );
2471
-      if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2472
-        $week = substr( $week, 1 );
2772
+      if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) {
2773
+              $week = substr( $week, 1 );
2774
+      }
2473 2775
       $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2776
+    } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
2777
+          return FALSE;
2778
+    } else {
2779
+          $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2474 2780
     }
2475
-    elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2476
-      return FALSE;
2477
-    else
2478
-      $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2479 2781
     return TRUE;
2480 2782
   }
2481 2783
 /*********************************************************************************/
@@ -2490,31 +2792,37 @@  discard block
 block discarded – undo
2490 2792
  * @return string
2491 2793
  */
2492 2794
   function createExdate() {
2493
-    if( empty( $this->exdate )) return FALSE;
2795
+    if( empty( $this->exdate )) {
2796
+        return FALSE;
2797
+    }
2494 2798
     $output = null;
2495 2799
     foreach( $this->exdate as $ex => $theExdate ) {
2496 2800
       if( empty( $theExdate['value'] )) {
2497
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2801
+        if( $this->getConfig( 'allowEmpty' )) {
2802
+            $output .= $this->_createElement( 'EXDATE' );
2803
+        }
2498 2804
         continue;
2499 2805
       }
2500 2806
       $content = $attributes = null;
2501 2807
       foreach( $theExdate['value'] as $eix => $exdatePart ) {
2502 2808
         $parno = count( $exdatePart );
2503 2809
         $formatted = $this->_format_date_time( $exdatePart, $parno );
2504
-        if( isset( $theExdate['params']['TZID'] ))
2505
-          $formatted = str_replace( 'Z', '', $formatted);
2810
+        if( isset( $theExdate['params']['TZID'] )) {
2811
+                  $formatted = str_replace( 'Z', '', $formatted);
2812
+        }
2506 2813
         if( 0 < $eix ) {
2507 2814
           if( isset( $theExdate['value'][0]['tz'] )) {
2508 2815
             if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2509 2816
                ( 'Z' == $theExdate['value'][0]['tz'] )) {
2510
-              if( 'Z' != substr( $formatted, -1 ))
2511
-                $formatted .= 'Z';
2817
+              if( 'Z' != substr( $formatted, -1 )) {
2818
+                              $formatted .= 'Z';
2819
+              }
2820
+            } else {
2821
+                          $formatted = str_replace( 'Z', '', $formatted );
2512 2822
             }
2513
-            else
2514
-              $formatted = str_replace( 'Z', '', $formatted );
2823
+          } else {
2824
+                      $formatted = str_replace( 'Z', '', $formatted );
2515 2825
           }
2516
-          else
2517
-            $formatted = str_replace( 'Z', '', $formatted );
2518 2826
         }
2519 2827
         $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2520 2828
       }
@@ -2538,34 +2846,39 @@  discard block
 block discarded – undo
2538 2846
       if( $this->getConfig( 'allowEmpty' )) {
2539 2847
         $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2540 2848
         return TRUE;
2849
+      } else {
2850
+              return FALSE;
2541 2851
       }
2542
-      else
2543
-        return FALSE;
2544 2852
     }
2545 2853
     $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
2546 2854
             /* ev. check 1:st date and save ev. timezone **/
2547 2855
     $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2548 2856
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2549 2857
     foreach( $exdates as $eix => $theExdate ) {
2550
-      if( $this->_isArrayTimestampDate( $theExdate ))
2551
-        $exdatea = $this->_timestamp2date( $theExdate, $parno );
2552
-      elseif(  is_array( $theExdate ))
2553
-        $exdatea = $this->_date_time_array( $theExdate, $parno );
2554
-      elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2858
+      if( $this->_isArrayTimestampDate( $theExdate )) {
2859
+              $exdatea = $this->_timestamp2date( $theExdate, $parno );
2860
+      } elseif(  is_array( $theExdate )) {
2861
+              $exdatea = $this->_date_time_array( $theExdate, $parno );
2862
+      } elseif( 8 <= strlen( trim( $theExdate ))) {
2863
+          // ex. 2006-08-03 10:12:18
2555 2864
         $exdatea = $this->_date_time_string( $theExdate, $parno );
2556
-      if( 3 == $parno )
2557
-        unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2558
-      elseif( isset( $exdatea['tz'] ))
2559
-        $exdatea['tz'] = (string) $exdatea['tz'];
2865
+      }
2866
+      if( 3 == $parno ) {
2867
+              unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2868
+      } elseif( isset( $exdatea['tz'] )) {
2869
+              $exdatea['tz'] = (string) $exdatea['tz'];
2870
+      }
2560 2871
       if(  isset( $input['params']['TZID'] ) ||
2561 2872
          ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2562 2873
          ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2563
-         ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2564
-        unset( $exdatea['tz'] );
2874
+         ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
2875
+              unset( $exdatea['tz'] );
2876
+      }
2565 2877
       $input['value'][] = $exdatea;
2566 2878
     }
2567
-    if( 0 >= count( $input['value'] ))
2568
-      return FALSE;
2879
+    if( 0 >= count( $input['value'] )) {
2880
+          return FALSE;
2881
+    }
2569 2882
     if( 3 == $parno ) {
2570 2883
       $input['params']['VALUE'] = 'DATE';
2571 2884
       unset( $input['params']['TZID'] );
@@ -2585,7 +2898,9 @@  discard block
 block discarded – undo
2585 2898
  * @return string
2586 2899
  */
2587 2900
   function createExrule() {
2588
-    if( empty( $this->exrule )) return FALSE;
2901
+    if( empty( $this->exrule )) {
2902
+        return FALSE;
2903
+    }
2589 2904
     return $this->_format_recur( 'EXRULE', $this->exrule );
2590 2905
   }
2591 2906
 /**
@@ -2599,7 +2914,11 @@  discard block
 block discarded – undo
2599 2914
  * @return bool
2600 2915
  */
2601 2916
   function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2602
-    if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2917
+    if( empty( $exruleset )) {
2918
+        if( $this->getConfig( 'allowEmpty' )) $exruleset = null;
2919
+    } else {
2920
+        return FALSE;
2921
+    }
2603 2922
     $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2604 2923
     return TRUE;
2605 2924
   }
@@ -2615,11 +2934,15 @@  discard block
 block discarded – undo
2615 2934
  * @return string
2616 2935
  */
2617 2936
   function createFreebusy() {
2618
-    if( empty( $this->freebusy )) return FALSE;
2937
+    if( empty( $this->freebusy )) {
2938
+        return FALSE;
2939
+    }
2619 2940
     $output = null;
2620 2941
     foreach( $this->freebusy as $freebusyPart ) {
2621 2942
       if( empty( $freebusyPart['value'] )) {
2622
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2943
+        if( $this->getConfig( 'allowEmpty' )) {
2944
+            $output .= $this->_createElement( 'FREEBUSY' );
2945
+        }
2623 2946
         continue;
2624 2947
       }
2625 2948
       $attributes = $content = null;
@@ -2627,9 +2950,9 @@  discard block
 block discarded – undo
2627 2950
         $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2628 2951
         unset( $freebusyPart['value']['fbtype'] );
2629 2952
         $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2953
+      } else {
2954
+              $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2630 2955
       }
2631
-      else
2632
-        $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2633 2956
       $attributes .= $this->_createParams( $freebusyPart['params'] );
2634 2957
       $fno = 1;
2635 2958
       $cnt = count( $freebusyPart['value']);
@@ -2638,21 +2961,24 @@  discard block
 block discarded – undo
2638 2961
         $content .= $formatted;
2639 2962
         $content .= '/';
2640 2963
         $cnt2 = count( $freebusyPeriod[1]);
2641
-        if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2964
+        if( array_key_exists( 'year', $freebusyPeriod[1] )) {
2965
+            // date-time
2642 2966
           $cnt2 = 7;
2643
-        elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2967
+        } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) {
2968
+            // duration
2644 2969
           $cnt2 = 5;
2970
+        }
2645 2971
         if(( 7 == $cnt2 )   &&    // period=  -> date-time
2646 2972
             isset( $freebusyPeriod[1]['year'] )  &&
2647 2973
             isset( $freebusyPeriod[1]['month'] ) &&
2648 2974
             isset( $freebusyPeriod[1]['day'] )) {
2649 2975
           $content .= $this->_format_date_time( $freebusyPeriod[1] );
2650
-        }
2651
-        else {                                  // period=  -> dur-time
2976
+        } else {                                  // period=  -> dur-time
2652 2977
           $content .= $this->_format_duration( $freebusyPeriod[1] );
2653 2978
         }
2654
-        if( $fno < $cnt )
2655
-          $content .= ',';
2979
+        if( $fno < $cnt ) {
2980
+                  $content .= ',';
2981
+        }
2656 2982
         $fno++;
2657 2983
       }
2658 2984
       $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
@@ -2675,14 +3001,15 @@  discard block
 block discarded – undo
2675 3001
       if( $this->getConfig( 'allowEmpty' )) {
2676 3002
         $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2677 3003
         return TRUE;
3004
+      } else {
3005
+              return FALSE;
2678 3006
       }
2679
-      else
2680
-        return FALSE;
2681 3007
     }
2682 3008
     $fbType = strtoupper( $fbType );
2683 3009
     if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2684
-       ( 'X-' != substr( $fbType, 0, 2 )))
2685
-      $fbType = 'BUSY';
3010
+       ( 'X-' != substr( $fbType, 0, 2 ))) {
3011
+          $fbType = 'BUSY';
3012
+    }
2686 3013
     $input = array( 'fbtype' => $fbType );
2687 3014
     foreach( $fbValues as $fbPeriod ) {   // periods => period
2688 3015
       $freebusyPeriod = array();
@@ -2692,22 +3019,19 @@  discard block
 block discarded – undo
2692 3019
           if( $this->_isArrayDate( $fbMember )) { // date-time value
2693 3020
             $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2694 3021
             $freebusyPairMember['tz'] = 'Z';
2695
-          }
2696
-          elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
3022
+          } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2697 3023
             $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2698 3024
             $freebusyPairMember['tz'] = 'Z';
2699
-          }
2700
-          else {                                         // array format duration
3025
+          } else {                                         // array format duration
2701 3026
             $freebusyPairMember = $this->_duration_array( $fbMember );
2702 3027
           }
2703
-        }
2704
-        elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
3028
+        } elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2705 3029
                ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2706
-          if( 'P' != $fbMember{0} )
2707
-            $fbmember = substr( $fbMember, 1 );
3030
+          if( 'P' != $fbMember{0} ) {
3031
+                      $fbmember = substr( $fbMember, 1 );
3032
+          }
2708 3033
           $freebusyPairMember = $this->_duration_string( $fbMember );
2709
-        }
2710
-        elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
3034
+        } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2711 3035
           $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2712 3036
           $freebusyPairMember['tz'] = 'Z';
2713 3037
         }
@@ -2730,9 +3054,12 @@  discard block
 block discarded – undo
2730 3054
  * @return string
2731 3055
  */
2732 3056
   function createGeo() {
2733
-    if( empty( $this->geo )) return FALSE;
2734
-    if( empty( $this->geo['value'] ))
2735
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3057
+    if( empty( $this->geo )) {
3058
+        return FALSE;
3059
+    }
3060
+    if( empty( $this->geo['value'] )) {
3061
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3062
+    }
2736 3063
     $attributes = $this->_createParams( $this->geo['params'] );
2737 3064
     $content    = null;
2738 3065
     $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
@@ -2752,15 +3079,17 @@  discard block
 block discarded – undo
2752 3079
  */
2753 3080
   function setGeo( $latitude, $longitude, $params=FALSE ) {
2754 3081
     if( !empty( $latitude ) && !empty( $longitude )) {
2755
-      if( !is_array( $this->geo )) $this->geo = array();
3082
+      if( !is_array( $this->geo )) {
3083
+          $this->geo = array();
3084
+      }
2756 3085
       $this->geo['value']['latitude']  = $latitude;
2757 3086
       $this->geo['value']['longitude'] = $longitude;
2758 3087
       $this->geo['params'] = $this->_setParams( $params );
3088
+    } elseif( $this->getConfig( 'allowEmpty' )) {
3089
+          $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3090
+    } else {
3091
+          return FALSE;
2759 3092
     }
2760
-    elseif( $this->getConfig( 'allowEmpty' ))
2761
-      $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2762
-    else
2763
-      return FALSE;
2764 3093
     return TRUE;
2765 3094
   }
2766 3095
 /*********************************************************************************/
@@ -2775,7 +3104,9 @@  discard block
 block discarded – undo
2775 3104
  * @return string
2776 3105
  */
2777 3106
   function createLastModified() {
2778
-    if( empty( $this->lastmodified )) return FALSE;
3107
+    if( empty( $this->lastmodified )) {
3108
+        return FALSE;
3109
+    }
2779 3110
     $attributes = $this->_createParams( $this->lastmodified['params'] );
2780 3111
     $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2781 3112
     return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
@@ -2795,8 +3126,9 @@  discard block
 block discarded – undo
2795 3126
  * @return boll
2796 3127
  */
2797 3128
   function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798
-    if( empty( $year ))
2799
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3129
+    if( empty( $year )) {
3130
+          $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3131
+    }
2800 3132
     $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2801 3133
     return TRUE;
2802 3134
   }
@@ -2812,9 +3144,12 @@  discard block
 block discarded – undo
2812 3144
  * @return string
2813 3145
  */
2814 3146
   function createLocation() {
2815
-    if( empty( $this->location )) return FALSE;
2816
-    if( empty( $this->location['value'] ))
2817
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3147
+    if( empty( $this->location )) {
3148
+        return FALSE;
3149
+    }
3150
+    if( empty( $this->location['value'] )) {
3151
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3152
+    }
2818 3153
     $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2819 3154
     $content    = $this->_strrep( $this->location['value'] );
2820 3155
     return $this->_createElement( 'LOCATION', $attributes, $content );
@@ -2829,7 +3164,11 @@  discard block
 block discarded – undo
2829 3164
  * @return bool
2830 3165
  */
2831 3166
   function setLocation( $value, $params=FALSE ) {
2832
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3167
+    if( empty( $value )) {
3168
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3169
+    } else {
3170
+        return FALSE;
3171
+    }
2833 3172
     $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2834 3173
     return TRUE;
2835 3174
   }
@@ -2845,9 +3184,12 @@  discard block
 block discarded – undo
2845 3184
  * @return string
2846 3185
  */
2847 3186
   function createOrganizer() {
2848
-    if( empty( $this->organizer )) return FALSE;
2849
-    if( empty( $this->organizer['value'] ))
2850
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3187
+    if( empty( $this->organizer )) {
3188
+        return FALSE;
3189
+    }
3190
+    if( empty( $this->organizer['value'] )) {
3191
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3192
+    }
2851 3193
     $attributes = $this->_createParams( $this->organizer['params']
2852 3194
                                       , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2853 3195
     $content    = 'MAILTO:'.$this->organizer['value'];
@@ -2863,13 +3205,18 @@  discard block
 block discarded – undo
2863 3205
  * @return bool
2864 3206
  */
2865 3207
   function setOrganizer( $value, $params=FALSE ) {
2866
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3208
+    if( empty( $value )) {
3209
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3210
+    } else {
3211
+        return FALSE;
3212
+    }
2867 3213
     $value = str_replace ( 'MAILTO:', '', $value );
2868 3214
     $value = str_replace ( 'mailto:', '', $value );
2869 3215
     $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2870 3216
     if( isset( $this->organizer['params']['SENT-BY'] )) {
2871
-      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2872
-        $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3217
+      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) {
3218
+              $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3219
+      }
2873 3220
     }
2874 3221
     return TRUE;
2875 3222
   }
@@ -2885,9 +3232,12 @@  discard block
 block discarded – undo
2885 3232
  * @return string
2886 3233
  */
2887 3234
   function createPercentComplete() {
2888
-    if( empty( $this->percentcomplete )) return FALSE;
2889
-    if( empty( $this->percentcomplete['value'] ))
2890
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3235
+    if( empty( $this->percentcomplete )) {
3236
+        return FALSE;
3237
+    }
3238
+    if( empty( $this->percentcomplete['value'] )) {
3239
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3240
+    }
2891 3241
     $attributes = $this->_createParams( $this->percentcomplete['params'] );
2892 3242
     return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2893 3243
   }
@@ -2901,7 +3251,11 @@  discard block
 block discarded – undo
2901 3251
  * @return bool
2902 3252
  */
2903 3253
   function setPercentComplete( $value, $params=FALSE ) {
2904
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3254
+    if( empty( $value )) {
3255
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3256
+    } else {
3257
+        return FALSE;
3258
+    }
2905 3259
     $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2906 3260
     return TRUE;
2907 3261
   }
@@ -2917,9 +3271,12 @@  discard block
 block discarded – undo
2917 3271
  * @return string
2918 3272
  */
2919 3273
   function createPriority() {
2920
-    if( empty( $this->priority )) return FALSE;
2921
-    if( empty( $this->priority['value'] ))
2922
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3274
+    if( empty( $this->priority )) {
3275
+        return FALSE;
3276
+    }
3277
+    if( empty( $this->priority['value'] )) {
3278
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3279
+    }
2923 3280
     $attributes = $this->_createParams( $this->priority['params'] );
2924 3281
     return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2925 3282
   }
@@ -2933,7 +3290,11 @@  discard block
 block discarded – undo
2933 3290
  * @return bool
2934 3291
  */
2935 3292
   function setPriority( $value, $params=FALSE  ) {
2936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3293
+    if( empty( $value )) {
3294
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3295
+    } else {
3296
+        return FALSE;
3297
+    }
2937 3298
     $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2938 3299
     return TRUE;
2939 3300
   }
@@ -2949,18 +3310,24 @@  discard block
 block discarded – undo
2949 3310
  * @return string
2950 3311
  */
2951 3312
   function createRdate() {
2952
-    if( empty( $this->rdate )) return FALSE;
3313
+    if( empty( $this->rdate )) {
3314
+        return FALSE;
3315
+    }
2953 3316
     $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2954 3317
     $output = null;
2955
-    if( $utctime  )
2956
-      unset( $this->rdate['params']['TZID'] );
3318
+    if( $utctime  ) {
3319
+          unset( $this->rdate['params']['TZID'] );
3320
+    }
2957 3321
     foreach( $this->rdate as $theRdate ) {
2958 3322
       if( empty( $theRdate['value'] )) {
2959
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
3323
+        if( $this->getConfig( 'allowEmpty' )) {
3324
+            $output .= $this->_createElement( 'RDATE' );
3325
+        }
2960 3326
         continue;
2961 3327
       }
2962
-      if( $utctime  )
2963
-        unset( $theRdate['params']['TZID'] );
3328
+      if( $utctime  ) {
3329
+              unset( $theRdate['params']['TZID'] );
3330
+      }
2964 3331
       $attributes = $this->_createParams( $theRdate['params'] );
2965 3332
       $cnt = count( $theRdate['value'] );
2966 3333
       $content = null;
@@ -2969,68 +3336,84 @@  discard block
 block discarded – undo
2969 3336
         $contentPart = null;
2970 3337
         if( is_array( $rdatePart ) &&
2971 3338
             isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2972
-          if( $utctime )
2973
-            unset( $rdatePart[0]['tz'] );
3339
+          if( $utctime ) {
3340
+                      unset( $rdatePart[0]['tz'] );
3341
+          }
2974 3342
           $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2975
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
2976
-            $formatted = str_replace( 'Z', '', $formatted);
3343
+          if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3344
+                      $formatted = str_replace( 'Z', '', $formatted);
3345
+          }
2977 3346
           if( 0 < $rpix ) {
2978 3347
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2979
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3348
+              if( 'Z' != substr( $formatted, -1 )) {
3349
+                  $formatted .= 'Z';
3350
+              }
3351
+            } else {
3352
+                          $formatted = str_replace( 'Z', '', $formatted );
2980 3353
             }
2981
-            else
2982
-              $formatted = str_replace( 'Z', '', $formatted );
2983 3354
           }
2984 3355
           $contentPart .= $formatted;
2985 3356
           $contentPart .= '/';
2986 3357
           $cnt2 = count( $rdatePart[1]);
2987 3358
           if( array_key_exists( 'year', $rdatePart[1] )) {
2988
-            if( array_key_exists( 'hour', $rdatePart[1] ))
2989
-              $cnt2 = 7;                                      // date-time
2990
-            else
2991
-              $cnt2 = 3;                                      // date
2992
-          }
2993
-          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
3359
+            if( array_key_exists( 'hour', $rdatePart[1] )) {
3360
+                          $cnt2 = 7;
3361
+            }
3362
+            // date-time
3363
+            else {
3364
+                          $cnt2 = 3;
3365
+            }
3366
+            // date
3367
+          } elseif( array_key_exists( 'week', $rdatePart[1] )) {
3368
+              // duration
2994 3369
             $cnt2 = 5;
3370
+          }
2995 3371
           if(( 7 == $cnt2 )   &&    // period=  -> date-time
2996 3372
               isset( $rdatePart[1]['year'] )  &&
2997 3373
               isset( $rdatePart[1]['month'] ) &&
2998 3374
               isset( $rdatePart[1]['day'] )) {
2999
-            if( $utctime )
3000
-              unset( $rdatePart[1]['tz'] );
3375
+            if( $utctime ) {
3376
+                          unset( $rdatePart[1]['tz'] );
3377
+            }
3001 3378
             $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3002
-            if( $utctime || !empty( $theRdate['params']['TZID'] ))
3003
-              $formatted = str_replace( 'Z', '', $formatted);
3379
+            if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3380
+                          $formatted = str_replace( 'Z', '', $formatted);
3381
+            }
3004 3382
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3005
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3383
+              if( 'Z' != substr( $formatted, -1 )) {
3384
+                  $formatted .= 'Z';
3385
+              }
3386
+            } else {
3387
+                          $formatted = str_replace( 'Z', '', $formatted );
3006 3388
             }
3007
-            else
3008
-              $formatted = str_replace( 'Z', '', $formatted );
3009 3389
            $contentPart .= $formatted;
3010
-          }
3011
-          else {                                  // period=  -> dur-time
3390
+          } else {                                  // period=  -> dur-time
3012 3391
             $contentPart .= $this->_format_duration( $rdatePart[1] );
3013 3392
           }
3014 3393
         } // PERIOD end
3015 3394
         else { // SINGLE date start
3016
-          if( $utctime )
3017
-            unset( $rdatePart['tz'] );
3395
+          if( $utctime ) {
3396
+                      unset( $rdatePart['tz'] );
3397
+          }
3018 3398
           $formatted = $this->_format_date_time( $rdatePart);
3019
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
3020
-            $formatted = str_replace( 'Z', '', $formatted);
3399
+          if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3400
+                      $formatted = str_replace( 'Z', '', $formatted);
3401
+          }
3021 3402
           if( !$utctime && ( 0 < $rpix )) {
3022 3403
             if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3023
-              if( 'Z' != substr( $formatted, -1 ))
3024
-                $formatted .= 'Z';
3404
+              if( 'Z' != substr( $formatted, -1 )) {
3405
+                              $formatted .= 'Z';
3406
+              }
3407
+            } else {
3408
+                          $formatted = str_replace( 'Z', '', $formatted );
3025 3409
             }
3026
-            else
3027
-              $formatted = str_replace( 'Z', '', $formatted );
3028 3410
           }
3029 3411
           $contentPart .= $formatted;
3030 3412
         }
3031 3413
         $content .= $contentPart;
3032
-        if( $rno < $cnt )
3033
-          $content .= ',';
3414
+        if( $rno < $cnt ) {
3415
+                  $content .= ',';
3416
+        }
3034 3417
         $rno++;
3035 3418
       }
3036 3419
       $output    .= $this->_createElement( 'RDATE', $attributes, $content );
@@ -3052,9 +3435,9 @@  discard block
 block discarded – undo
3052 3435
       if( $this->getConfig( 'allowEmpty' )) {
3053 3436
         $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3054 3437
         return TRUE;
3438
+      } else {
3439
+              return FALSE;
3055 3440
       }
3056
-      else
3057
-        return FALSE;
3058 3441
     }
3059 3442
     $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3060 3443
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
@@ -3068,15 +3451,19 @@  discard block
 block discarded – undo
3068 3451
     (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) ||
3069 3452
                                       $this->_isArrayDate( $rdates[0][0] ))) ||
3070 3453
                                     ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3071
-     ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3072
-      $input['params']['VALUE'] = 'PERIOD';
3454
+     ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) {
3455
+          $input['params']['VALUE'] = 'PERIOD';
3456
+    }
3073 3457
             /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3074 3458
     $date  = reset( $rdates );
3075
-    if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3459
+    if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) {
3460
+        // PERIOD
3076 3461
       $date  = reset( $date );
3462
+    }
3077 3463
     $this->_chkdatecfg( $date, $parno, $input['params'] );
3078
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3079
-      unset( $input['params']['TZID'] );
3464
+    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3465
+          unset( $input['params']['TZID'] );
3466
+    }
3080 3467
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3081 3468
     foreach( $rdates as $rpix => $theRdate ) {
3082 3469
       $inputa = null;
@@ -3084,48 +3471,60 @@  discard block
 block discarded – undo
3084 3471
         if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3085 3472
           foreach( $theRdate as $rix => $rPeriod ) {
3086 3473
             if( is_array( $rPeriod )) {
3087
-              if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3474
+              if( $this->_isArrayTimestampDate( $rPeriod )) {
3475
+                  // timestamp
3088 3476
                 $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3089
-              elseif( $this->_isArrayDate( $rPeriod ))
3090
-                $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3091
-              elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3477
+              } elseif( $this->_isArrayDate( $rPeriod )) {
3478
+                              $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3479
+              } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) {
3480
+                  // text-date
3092 3481
                 $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3093
-              else                                               // array format duration
3482
+              } else {
3483
+                  // array format duration
3094 3484
                 $inputab  = $this->_duration_array( $rPeriod );
3095
-            }
3096
-            elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3485
+              }
3486
+            } elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3097 3487
                    ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3098
-              if( 'P' != $rPeriod{0} )
3099
-                $rPeriod  = substr( $rPeriod, 1 );
3488
+              if( 'P' != $rPeriod{0} ) {
3489
+                              $rPeriod  = substr( $rPeriod, 1 );
3490
+              }
3100 3491
               $inputab    = $this->_duration_string( $rPeriod );
3101
-            }
3102
-            elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3492
+            } elseif( 8 <= strlen( trim( $rPeriod ))) {
3493
+                // text date ex. 2006-08-03 10:12:18
3103 3494
               $inputab    = $this->_date_time_string( $rPeriod, $parno );
3495
+            }
3104 3496
             if(  isset( $input['params']['TZID'] ) ||
3105 3497
                ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3106 3498
                ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3107
-               ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3108
-              unset( $inputab['tz'] );
3499
+               ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) {
3500
+                          unset( $inputab['tz'] );
3501
+            }
3109 3502
             $inputa[]     = $inputab;
3110 3503
           }
3111 3504
         } // PERIOD end
3112
-        elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3505
+        elseif ( $this->_isArrayTimestampDate( $theRdate )) {
3506
+            // timestamp
3113 3507
           $inputa = $this->_timestamp2date( $theRdate, $parno );
3114
-        else                                                     // date[-time]
3508
+        } else {
3509
+            // date[-time]
3115 3510
           $inputa = $this->_date_time_array( $theRdate, $parno );
3116
-      }
3117
-      elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3511
+        }
3512
+      } elseif( 8 <= strlen( trim( $theRdate ))) {
3513
+          // text date ex. 2006-08-03 10:12:18
3118 3514
         $inputa       = $this->_date_time_string( $theRdate, $parno );
3515
+      }
3119 3516
       if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3120
-        if( 3 == $parno )
3121
-          unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3122
-        elseif( isset( $inputa['tz'] ))
3123
-          $inputa['tz'] = (string) $inputa['tz'];
3517
+        if( 3 == $parno ) {
3518
+                  unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3519
+        } elseif( isset( $inputa['tz'] )) {
3520
+                  $inputa['tz'] = (string) $inputa['tz'];
3521
+        }
3124 3522
         if(  isset( $input['params']['TZID'] ) ||
3125 3523
            ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3126 3524
            ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3127
-           ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3128
-          unset( $inputa['tz'] );
3525
+           ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
3526
+                  unset( $inputa['tz'] );
3527
+        }
3129 3528
       }
3130 3529
       $input['value'][] = $inputa;
3131 3530
     }
@@ -3148,9 +3547,12 @@  discard block
 block discarded – undo
3148 3547
  * @return string
3149 3548
  */
3150 3549
   function createRecurrenceid() {
3151
-    if( empty( $this->recurrenceid )) return FALSE;
3152
-    if( empty( $this->recurrenceid['value'] ))
3153
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3550
+    if( empty( $this->recurrenceid )) {
3551
+        return FALSE;
3552
+    }
3553
+    if( empty( $this->recurrenceid['value'] )) {
3554
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3555
+    }
3154 3556
     $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3155 3557
     $attributes = $this->_createParams( $this->recurrenceid['params'] );
3156 3558
     return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
@@ -3174,9 +3576,9 @@  discard block
 block discarded – undo
3174 3576
       if( $this->getConfig( 'allowEmpty' )) {
3175 3577
         $this->recurrenceid = array( 'value' => null, 'params' => null );
3176 3578
         return TRUE;
3579
+      } else {
3580
+              return FALSE;
3177 3581
       }
3178
-      else
3179
-        return FALSE;
3180 3582
     }
3181 3583
     $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3182 3584
     return TRUE;
@@ -3193,11 +3595,15 @@  discard block
 block discarded – undo
3193 3595
  * @return string
3194 3596
  */
3195 3597
   function createRelatedTo() {
3196
-    if( empty( $this->relatedto )) return FALSE;
3598
+    if( empty( $this->relatedto )) {
3599
+        return FALSE;
3600
+    }
3197 3601
     $output = null;
3198 3602
     foreach( $this->relatedto as $relation ) {
3199 3603
       if( empty( $relation['value'] )) {
3200
-        if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3604
+        if( $this->getConfig( 'allowEmpty' )) {
3605
+            $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3606
+        }
3201 3607
         continue;
3202 3608
       }
3203 3609
       $attributes = $this->_createParams( $relation['params'] );
@@ -3219,9 +3625,14 @@  discard block
 block discarded – undo
3219 3625
  * @return bool
3220 3626
  */
3221 3627
   function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3222
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3223
-    if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3224
-      $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3628
+    if( empty( $value )) {
3629
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3630
+    } else {
3631
+        return FALSE;
3632
+    }
3633
+    if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) {
3634
+          $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3635
+    }
3225 3636
     $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3226 3637
     $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3227 3638
     return TRUE;
@@ -3238,9 +3649,12 @@  discard block
 block discarded – undo
3238 3649
  * @return string
3239 3650
  */
3240 3651
   function createRepeat() {
3241
-    if( empty( $this->repeat )) return FALSE;
3242
-    if( empty( $this->repeat['value'] ))
3243
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3652
+    if( empty( $this->repeat )) {
3653
+        return FALSE;
3654
+    }
3655
+    if( empty( $this->repeat['value'] )) {
3656
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3657
+    }
3244 3658
     $attributes = $this->_createParams( $this->repeat['params'] );
3245 3659
     return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3246 3660
   }
@@ -3254,7 +3668,11 @@  discard block
 block discarded – undo
3254 3668
  * @return void
3255 3669
  */
3256 3670
   function setRepeat( $value, $params=FALSE ) {
3257
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3671
+    if( empty( $value )) {
3672
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3673
+    } else {
3674
+        return FALSE;
3675
+    }
3258 3676
     $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3259 3677
     return TRUE;
3260 3678
   }
@@ -3269,18 +3687,23 @@  discard block
 block discarded – undo
3269 3687
  * @return string
3270 3688
  */
3271 3689
   function createRequestStatus() {
3272
-    if( empty( $this->requeststatus )) return FALSE;
3690
+    if( empty( $this->requeststatus )) {
3691
+        return FALSE;
3692
+    }
3273 3693
     $output = null;
3274 3694
     foreach( $this->requeststatus as $rstat ) {
3275 3695
       if( empty( $rstat['value']['statcode'] )) {
3276
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3696
+        if( $this->getConfig( 'allowEmpty' )) {
3697
+            $output .= $this->_createElement( 'REQUEST-STATUS' );
3698
+        }
3277 3699
         continue;
3278 3700
       }
3279 3701
       $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3280 3702
       $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3281 3703
       $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3282
-      if( isset( $rstat['value']['extdata'] ))
3283
-        $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3704
+      if( isset( $rstat['value']['extdata'] )) {
3705
+              $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3706
+      }
3284 3707
       $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3285 3708
     }
3286 3709
     return $output;
@@ -3298,10 +3721,15 @@  discard block
 block discarded – undo
3298 3721
  * @return bool
3299 3722
  */
3300 3723
   function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3301
-    if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3724
+    if( empty( $statcode ) || empty( $text )) {
3725
+        if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null;
3726
+    } else {
3727
+        return FALSE;
3728
+    }
3302 3729
     $input              = array( 'statcode' => $statcode, 'text' => $text );
3303
-    if( $extdata )
3304
-      $input['extdata'] = $extdata;
3730
+    if( $extdata ) {
3731
+          $input['extdata'] = $extdata;
3732
+    }
3305 3733
     $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3306 3734
     return TRUE;
3307 3735
   }
@@ -3317,21 +3745,26 @@  discard block
 block discarded – undo
3317 3745
  * @return string
3318 3746
  */
3319 3747
   function createResources() {
3320
-    if( empty( $this->resources )) return FALSE;
3748
+    if( empty( $this->resources )) {
3749
+        return FALSE;
3750
+    }
3321 3751
     $output = null;
3322 3752
     foreach( $this->resources as $resource ) {
3323 3753
       if( empty( $resource['value'] )) {
3324
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3754
+        if( $this->getConfig( 'allowEmpty' )) {
3755
+            $output .= $this->_createElement( 'RESOURCES' );
3756
+        }
3325 3757
         continue;
3326 3758
       }
3327 3759
       $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3328 3760
       if( is_array( $resource['value'] )) {
3329
-        foreach( $resource['value'] as $rix => $resourcePart )
3330
-          $resource['value'][$rix] = $this->_strrep( $resourcePart );
3761
+        foreach( $resource['value'] as $rix => $resourcePart ) {
3762
+                  $resource['value'][$rix] = $this->_strrep( $resourcePart );
3763
+        }
3331 3764
         $content   = implode( ',', $resource['value'] );
3765
+      } else {
3766
+              $content   = $this->_strrep( $resource['value'] );
3332 3767
       }
3333
-      else
3334
-        $content   = $this->_strrep( $resource['value'] );
3335 3768
       $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3336 3769
     }
3337 3770
     return $output;
@@ -3347,7 +3780,11 @@  discard block
 block discarded – undo
3347 3780
  * @return bool
3348 3781
  */
3349 3782
   function setResources( $value, $params=FALSE, $index=FALSE ) {
3350
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3783
+    if( empty( $value )) {
3784
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3785
+    } else {
3786
+        return FALSE;
3787
+    }
3351 3788
     $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3352 3789
     return TRUE;
3353 3790
   }
@@ -3363,7 +3800,9 @@  discard block
 block discarded – undo
3363 3800
  * @return string
3364 3801
  */
3365 3802
   function createRrule() {
3366
-    if( empty( $this->rrule )) return FALSE;
3803
+    if( empty( $this->rrule )) {
3804
+        return FALSE;
3805
+    }
3367 3806
     return $this->_format_recur( 'RRULE', $this->rrule );
3368 3807
   }
3369 3808
 /**
@@ -3377,7 +3816,11 @@  discard block
 block discarded – undo
3377 3816
  * @return void
3378 3817
  */
3379 3818
   function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380
-    if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3819
+    if( empty( $rruleset )) {
3820
+        if( $this->getConfig( 'allowEmpty' )) $rruleset = null;
3821
+    } else {
3822
+        return FALSE;
3823
+    }
3381 3824
     $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3382 3825
     return TRUE;
3383 3826
   }
@@ -3392,9 +3835,12 @@  discard block
 block discarded – undo
3392 3835
  * @return string
3393 3836
  */
3394 3837
   function createSequence() {
3395
-    if( empty( $this->sequence )) return FALSE;
3396
-    if( empty( $this->sequence['value'] ))
3397
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3838
+    if( empty( $this->sequence )) {
3839
+        return FALSE;
3840
+    }
3841
+    if( empty( $this->sequence['value'] )) {
3842
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3843
+    }
3398 3844
     $attributes = $this->_createParams( $this->sequence['params'] );
3399 3845
     return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3400 3846
   }
@@ -3407,8 +3853,9 @@  discard block
 block discarded – undo
3407 3853
  * @return bool
3408 3854
  */
3409 3855
   function setSequence( $value=FALSE, $params=FALSE ) {
3410
-    if( empty( $value ))
3411
-      $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3856
+    if( empty( $value )) {
3857
+          $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3858
+    }
3412 3859
     $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3413 3860
     return TRUE;
3414 3861
   }
@@ -3424,9 +3871,12 @@  discard block
 block discarded – undo
3424 3871
  * @return string
3425 3872
  */
3426 3873
   function createStatus() {
3427
-    if( empty( $this->status )) return FALSE;
3428
-    if( empty( $this->status['value'] ))
3429
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3874
+    if( empty( $this->status )) {
3875
+        return FALSE;
3876
+    }
3877
+    if( empty( $this->status['value'] )) {
3878
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3879
+    }
3430 3880
     $attributes = $this->_createParams( $this->status['params'] );
3431 3881
     return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3432 3882
   }
@@ -3440,7 +3890,11 @@  discard block
 block discarded – undo
3440 3890
  * @return bool
3441 3891
  */
3442 3892
   function setStatus( $value, $params=FALSE ) {
3443
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3893
+    if( empty( $value )) {
3894
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3895
+    } else {
3896
+        return FALSE;
3897
+    }
3444 3898
     $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3445 3899
     return TRUE;
3446 3900
   }
@@ -3456,9 +3910,12 @@  discard block
 block discarded – undo
3456 3910
  * @return string
3457 3911
  */
3458 3912
   function createSummary() {
3459
-    if( empty( $this->summary )) return FALSE;
3460
-    if( empty( $this->summary['value'] ))
3461
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3913
+    if( empty( $this->summary )) {
3914
+        return FALSE;
3915
+    }
3916
+    if( empty( $this->summary['value'] )) {
3917
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3918
+    }
3462 3919
     $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3463 3920
     $content    = $this->_strrep( $this->summary['value'] );
3464 3921
     return $this->_createElement( 'SUMMARY', $attributes, $content );
@@ -3473,7 +3930,11 @@  discard block
 block discarded – undo
3473 3930
  * @return bool
3474 3931
  */
3475 3932
   function setSummary( $value, $params=FALSE ) {
3476
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3933
+    if( empty( $value )) {
3934
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3935
+    } else {
3936
+        return FALSE;
3937
+    }
3477 3938
     $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3478 3939
     return TRUE;
3479 3940
   }
@@ -3489,9 +3950,12 @@  discard block
 block discarded – undo
3489 3950
  * @return string
3490 3951
  */
3491 3952
   function createTransp() {
3492
-    if( empty( $this->transp )) return FALSE;
3493
-    if( empty( $this->transp['value'] ))
3494
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3953
+    if( empty( $this->transp )) {
3954
+        return FALSE;
3955
+    }
3956
+    if( empty( $this->transp['value'] )) {
3957
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3958
+    }
3495 3959
     $attributes = $this->_createParams( $this->transp['params'] );
3496 3960
     return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3497 3961
   }
@@ -3505,7 +3969,11 @@  discard block
 block discarded – undo
3505 3969
  * @return bool
3506 3970
  */
3507 3971
   function setTransp( $value, $params=FALSE ) {
3508
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3972
+    if( empty( $value )) {
3973
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3974
+    } else {
3975
+        return FALSE;
3976
+    }
3509 3977
     $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3510 3978
     return TRUE;
3511 3979
   }
@@ -3521,19 +3989,24 @@  discard block
 block discarded – undo
3521 3989
  * @return string
3522 3990
  */
3523 3991
   function createTrigger() {
3524
-    if( empty( $this->trigger )) return FALSE;
3525
-    if( empty( $this->trigger['value'] ))
3526
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3992
+    if( empty( $this->trigger )) {
3993
+        return FALSE;
3994
+    }
3995
+    if( empty( $this->trigger['value'] )) {
3996
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3997
+    }
3527 3998
     $content = $attributes = null;
3528 3999
     if( isset( $this->trigger['value']['year'] )   &&
3529 4000
         isset( $this->trigger['value']['month'] )  &&
3530
-        isset( $this->trigger['value']['day'] ))
3531
-      $content      .= $this->_format_date_time( $this->trigger['value'] );
3532
-    else {
3533
-      if( TRUE !== $this->trigger['value']['relatedStart'] )
3534
-        $attributes .= $this->intAttrDelimiter.'RELATED=END';
3535
-      if( $this->trigger['value']['before'] )
3536
-        $content    .= '-';
4001
+        isset( $this->trigger['value']['day'] )) {
4002
+          $content      .= $this->_format_date_time( $this->trigger['value'] );
4003
+    } else {
4004
+      if( TRUE !== $this->trigger['value']['relatedStart'] ) {
4005
+              $attributes .= $this->intAttrDelimiter.'RELATED=END';
4006
+      }
4007
+      if( $this->trigger['value']['before'] ) {
4008
+              $content    .= '-';
4009
+      }
3537 4010
       $content      .= $this->_format_duration( $this->trigger['value'] );
3538 4011
     }
3539 4012
     $attributes     .= $this->_createParams( $this->trigger['params'] );
@@ -3557,28 +4030,30 @@  discard block
 block discarded – undo
3557 4030
  * @return bool
3558 4031
  */
3559 4032
   function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3560
-    if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3561
-      if( $this->getConfig( 'allowEmpty' )) {
4033
+    if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
4034
+          if( $this->getConfig( 'allowEmpty' )) {
3562 4035
         $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
4036
+    }
3563 4037
         return TRUE;
4038
+      } else {
4039
+              return FALSE;
3564 4040
       }
3565
-      else
3566
-        return FALSE;
3567 4041
     if( $this->_isArrayTimestampDate( $year )) { // timestamp
3568 4042
       $params = $this->_setParams( $month );
3569 4043
       $date   = $this->_timestamp2date( $year, 7 );
3570
-      foreach( $date as $k => $v )
3571
-        $$k = $v;
3572
-    }
3573
-    elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
4044
+      foreach( $date as $k => $v ) {
4045
+              $$k = $v;
4046
+      }
4047
+    } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3574 4048
       $params = $this->_setParams( $month );
3575 4049
       if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3576 4050
            array_key_exists( 'month', $year ) &&
3577 4051
            array_key_exists( 'day',   $year ))) {  // so this must be a duration
3578
-        if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3579
-          $relatedStart = FALSE;
3580
-        else
3581
-          $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4052
+        if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) {
4053
+                  $relatedStart = FALSE;
4054
+        } else {
4055
+                  $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4056
+        }
3582 4057
         $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3583 4058
       }
3584 4059
       $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
@@ -3589,24 +4064,27 @@  discard block
 block discarded – undo
3589 4064
       $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3590 4065
       $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3591 4066
       $year  = $SSYY;
3592
-    }
3593
-    elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
4067
+    } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3594 4068
       $params = $this->_setParams( $month );
3595 4069
       if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3596 4070
         $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3597 4071
         $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3598
-        if(     'P'  != $year{0} )
3599
-          $year       = substr( $year, 1 );
4072
+        if(     'P'  != $year{0} ) {
4073
+                  $year       = substr( $year, 1 );
4074
+        }
3600 4075
         $date         = $this->_duration_string( $year);
3601
-      }
3602
-      else   // date
4076
+      } else {
4077
+          // date
3603 4078
         $date    = $this->_date_time_string( $year, 7 );
4079
+      }
3604 4080
       unset( $year, $month, $day );
3605
-      foreach( $date as $k => $v )
3606
-        $$k = $v;
3607
-    }
3608
-    else // single values in function input parameters
4081
+      foreach( $date as $k => $v ) {
4082
+              $$k = $v;
4083
+      }
4084
+    } else {
4085
+        // single values in function input parameters
3609 4086
       $params = $this->_setParams( $params );
4087
+    }
3610 4088
     if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3611 4089
       $params['VALUE'] = 'DATE-TIME';
3612 4090
       $hour = ( $hour ) ? $hour : 0;
@@ -3621,8 +4099,7 @@  discard block
 block discarded – undo
3621 4099
                                      , 'sec'   => $sec
3622 4100
                                      , 'tz'    => 'Z' );
3623 4101
       return TRUE;
3624
-    }
3625
-    elseif(( empty( $year ) && empty( $month )) &&    // duration
4102
+    } elseif(( empty( $year ) && empty( $month )) &&    // duration
3626 4103
            (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3627 4104
       unset( $params['RELATED'] ); // set at output creation (END only)
3628 4105
       unset( $params['VALUE'] );   // 'DURATION' default
@@ -3631,11 +4108,21 @@  discard block
 block discarded – undo
3631 4108
       $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3632 4109
       $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3633 4110
                                       , 'before'       => $before );
3634
-      if( !empty( $week )) $this->trigger['value']['week'] = $week;
3635
-      if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3636
-      if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3637
-      if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3638
-      if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
4111
+      if( !empty( $week )) {
4112
+          $this->trigger['value']['week'] = $week;
4113
+      }
4114
+      if( !empty( $day  )) {
4115
+          $this->trigger['value']['day']  = $day;
4116
+      }
4117
+      if( !empty( $hour )) {
4118
+          $this->trigger['value']['hour'] = $hour;
4119
+      }
4120
+      if( !empty( $min  )) {
4121
+          $this->trigger['value']['min']  = $min;
4122
+      }
4123
+      if( !empty( $sec  )) {
4124
+          $this->trigger['value']['sec']  = $sec;
4125
+      }
3639 4126
       return TRUE;
3640 4127
     }
3641 4128
     return FALSE;
@@ -3652,9 +4139,12 @@  discard block
 block discarded – undo
3652 4139
  * @return string
3653 4140
  */
3654 4141
   function createTzid() {
3655
-    if( empty( $this->tzid )) return FALSE;
3656
-    if( empty( $this->tzid['value'] ))
3657
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4142
+    if( empty( $this->tzid )) {
4143
+        return FALSE;
4144
+    }
4145
+    if( empty( $this->tzid['value'] )) {
4146
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4147
+    }
3658 4148
     $attributes = $this->_createParams( $this->tzid['params'] );
3659 4149
     return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3660 4150
   }
@@ -3668,7 +4158,11 @@  discard block
 block discarded – undo
3668 4158
  * @return bool
3669 4159
  */
3670 4160
   function setTzid( $value, $params=FALSE ) {
3671
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4161
+    if( empty( $value )) {
4162
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4163
+    } else {
4164
+        return FALSE;
4165
+    }
3672 4166
     $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3673 4167
     return TRUE;
3674 4168
   }
@@ -3685,14 +4179,17 @@  discard block
 block discarded – undo
3685 4179
  * @return string
3686 4180
  */
3687 4181
   function createTzname() {
3688
-    if( empty( $this->tzname )) return FALSE;
4182
+    if( empty( $this->tzname )) {
4183
+        return FALSE;
4184
+    }
3689 4185
     $output = null;
3690 4186
     foreach( $this->tzname as $theName ) {
3691 4187
       if( !empty( $theName['value'] )) {
3692 4188
         $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3693 4189
         $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
4190
+      } elseif( $this->getConfig( 'allowEmpty' )) {
4191
+          $output .= $this->_createElement( 'TZNAME' );
3694 4192
       }
3695
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3696 4193
     }
3697 4194
     return $output;
3698 4195
   }
@@ -3707,7 +4204,11 @@  discard block
 block discarded – undo
3707 4204
  * @return bool
3708 4205
  */
3709 4206
   function setTzname( $value, $params=FALSE, $index=FALSE ) {
3710
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4207
+    if( empty( $value )) {
4208
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4209
+    } else {
4210
+        return FALSE;
4211
+    }
3711 4212
     $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3712 4213
     return TRUE;
3713 4214
   }
@@ -3723,9 +4224,12 @@  discard block
 block discarded – undo
3723 4224
  * @return string
3724 4225
  */
3725 4226
   function createTzoffsetfrom() {
3726
-    if( empty( $this->tzoffsetfrom )) return FALSE;
3727
-    if( empty( $this->tzoffsetfrom['value'] ))
3728
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4227
+    if( empty( $this->tzoffsetfrom )) {
4228
+        return FALSE;
4229
+    }
4230
+    if( empty( $this->tzoffsetfrom['value'] )) {
4231
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4232
+    }
3729 4233
     $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3730 4234
     return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3731 4235
   }
@@ -3739,7 +4243,11 @@  discard block
 block discarded – undo
3739 4243
  * @return bool
3740 4244
  */
3741 4245
   function setTzoffsetfrom( $value, $params=FALSE ) {
3742
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4246
+    if( empty( $value )) {
4247
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4248
+    } else {
4249
+        return FALSE;
4250
+    }
3743 4251
     $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3744 4252
     return TRUE;
3745 4253
   }
@@ -3755,9 +4263,12 @@  discard block
 block discarded – undo
3755 4263
  * @return string
3756 4264
  */
3757 4265
   function createTzoffsetto() {
3758
-    if( empty( $this->tzoffsetto )) return FALSE;
3759
-    if( empty( $this->tzoffsetto['value'] ))
3760
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4266
+    if( empty( $this->tzoffsetto )) {
4267
+        return FALSE;
4268
+    }
4269
+    if( empty( $this->tzoffsetto['value'] )) {
4270
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4271
+    }
3761 4272
     $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3762 4273
     return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3763 4274
   }
@@ -3771,7 +4282,11 @@  discard block
 block discarded – undo
3771 4282
  * @return bool
3772 4283
  */
3773 4284
   function setTzoffsetto( $value, $params=FALSE ) {
3774
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4285
+    if( empty( $value )) {
4286
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4287
+    } else {
4288
+        return FALSE;
4289
+    }
3775 4290
     $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3776 4291
     return TRUE;
3777 4292
   }
@@ -3787,9 +4302,12 @@  discard block
 block discarded – undo
3787 4302
  * @return string
3788 4303
  */
3789 4304
   function createTzurl() {
3790
-    if( empty( $this->tzurl )) return FALSE;
3791
-    if( empty( $this->tzurl['value'] ))
3792
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4305
+    if( empty( $this->tzurl )) {
4306
+        return FALSE;
4307
+    }
4308
+    if( empty( $this->tzurl['value'] )) {
4309
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4310
+    }
3793 4311
     $attributes = $this->_createParams( $this->tzurl['params'] );
3794 4312
     return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3795 4313
   }
@@ -3803,7 +4321,11 @@  discard block
 block discarded – undo
3803 4321
  * @return boll
3804 4322
  */
3805 4323
   function setTzurl( $value, $params=FALSE ) {
3806
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4324
+    if( empty( $value )) {
4325
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4326
+    } else {
4327
+        return FALSE;
4328
+    }
3807 4329
     $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3808 4330
     return TRUE;
3809 4331
   }
@@ -3819,8 +4341,9 @@  discard block
 block discarded – undo
3819 4341
  * @return string
3820 4342
  */
3821 4343
   function createUid() {
3822
-    if( 0 >= count( $this->uid ))
3823
-      $this->_makeuid();
4344
+    if( 0 >= count( $this->uid )) {
4345
+          $this->_makeuid();
4346
+    }
3824 4347
     $attributes = $this->_createParams( $this->uid['params'] );
3825 4348
     return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3826 4349
   }
@@ -3839,8 +4362,9 @@  discard block
 block discarded – undo
3839 4362
     $end    = strlen( $base ) - 1;
3840 4363
     $length = 6;
3841 4364
     $str    = null;
3842
-    for( $p = 0; $p < $length; $p++ )
3843
-      $unique .= $base{mt_rand( $start, $end )};
4365
+    for( $p = 0; $p < $length; $p++ ) {
4366
+          $unique .= $base{mt_rand( $start, $end )};
4367
+    }
3844 4368
     $this->uid = array( 'params' => null );
3845 4369
     $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3846 4370
   }
@@ -3854,7 +4378,10 @@  discard block
 block discarded – undo
3854 4378
  * @return bool
3855 4379
  */
3856 4380
   function setUid( $value, $params=FALSE ) {
3857
-    if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
4381
+    if( empty( $value )) {
4382
+        return FALSE;
4383
+    }
4384
+    // no allowEmpty check here !!!!
3858 4385
     $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3859 4386
     return TRUE;
3860 4387
   }
@@ -3870,9 +4397,12 @@  discard block
 block discarded – undo
3870 4397
  * @return string
3871 4398
  */
3872 4399
   function createUrl() {
3873
-    if( empty( $this->url )) return FALSE;
3874
-    if( empty( $this->url['value'] ))
3875
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4400
+    if( empty( $this->url )) {
4401
+        return FALSE;
4402
+    }
4403
+    if( empty( $this->url['value'] )) {
4404
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4405
+    }
3876 4406
     $attributes = $this->_createParams( $this->url['params'] );
3877 4407
     return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3878 4408
   }
@@ -3886,7 +4416,11 @@  discard block
 block discarded – undo
3886 4416
  * @return bool
3887 4417
  */
3888 4418
   function setUrl( $value, $params=FALSE ) {
3889
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4419
+    if( empty( $value )) {
4420
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4421
+    } else {
4422
+        return FALSE;
4423
+    }
3890 4424
     $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3891 4425
     return TRUE;
3892 4426
   }
@@ -3902,21 +4436,26 @@  discard block
 block discarded – undo
3902 4436
  * @return string
3903 4437
  */
3904 4438
   function createXprop() {
3905
-    if( empty( $this->xprop )) return FALSE;
4439
+    if( empty( $this->xprop )) {
4440
+        return FALSE;
4441
+    }
3906 4442
     $output = null;
3907 4443
     foreach( $this->xprop as $label => $xpropPart ) {
3908 4444
       if( empty( $xpropPart['value'] )) {
3909
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
4445
+        if( $this->getConfig( 'allowEmpty' )) {
4446
+            $output .= $this->_createElement( $label );
4447
+        }
3910 4448
         continue;
3911 4449
       }
3912 4450
       $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3913 4451
       if( is_array( $xpropPart['value'] )) {
3914
-        foreach( $xpropPart['value'] as $pix => $theXpart )
3915
-          $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4452
+        foreach( $xpropPart['value'] as $pix => $theXpart ) {
4453
+                  $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4454
+        }
3916 4455
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
4456
+      } else {
4457
+              $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3917 4458
       }
3918
-      else
3919
-        $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3920 4459
       $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3921 4460
     }
3922 4461
     return $output;
@@ -3932,12 +4471,20 @@  discard block
 block discarded – undo
3932 4471
  * @return bool
3933 4472
  */
3934 4473
   function setXprop( $label, $value, $params=FALSE ) {
3935
-    if( empty( $label )) return;
3936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4474
+    if( empty( $label )) {
4475
+        return;
4476
+    }
4477
+    if( empty( $value )) {
4478
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4479
+    } else {
4480
+        return FALSE;
4481
+    }
3937 4482
     $xprop           = array( 'value' => $value );
3938 4483
     $toolbox         = new calendarComponent();
3939 4484
     $xprop['params'] = $toolbox->_setParams( $params );
3940
-    if( !is_array( $this->xprop )) $this->xprop = array();
4485
+    if( !is_array( $this->xprop )) {
4486
+        $this->xprop = array();
4487
+    }
3941 4488
     $this->xprop[strtoupper( $label )] = $xprop;
3942 4489
     return TRUE;
3943 4490
   }
@@ -4005,30 +4552,29 @@  discard block
 block discarded – undo
4005 4552
         $attributes  = null;
4006 4553
         foreach( $attributes2 as $attribute ) {
4007 4554
           $attrKVarr = explode( '=', $attribute );
4008
-          if( empty( $attrKVarr[0] ))
4009
-            continue;
4555
+          if( empty( $attrKVarr[0] )) {
4556
+                      continue;
4557
+          }
4010 4558
           if( !isset( $attrKVarr[1] )) {
4011 4559
             $attrValue = $attrKVarr[0];
4012 4560
             $attrKey   = null;
4013
-          }
4014
-          elseif( 2 == count( $attrKVarr)) {
4561
+          } elseif( 2 == count( $attrKVarr)) {
4015 4562
             $attrKey   = strtolower( $attrKVarr[0] );
4016 4563
             $attrValue = $attrKVarr[1];
4017
-          }
4018
-          else {
4564
+          } else {
4019 4565
             $attrKey   = strtolower( $attrKVarr[0] );
4020 4566
             unset( $attrKVarr[0] );
4021 4567
             $attrValue = implode( '=', $attrKVarr );
4022 4568
           }
4023 4569
           if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4024 4570
             $attachInlineBinary = TRUE;
4025
-            if( 'fmttype' == $attrKey )
4026
-              $attachfmttype = $attrKey.'='.$attrValue;
4571
+            if( 'fmttype' == $attrKey ) {
4572
+                          $attachfmttype = $attrKey.'='.$attrValue;
4573
+            }
4027 4574
             continue;
4028
-          }
4029
-          elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4030
-            $categoriesAttrLang = $attrKey.'='.$attrValue;
4031
-          else {
4575
+          } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) {
4576
+                      $categoriesAttrLang = $attrKey.'='.$attrValue;
4577
+          } else {
4032 4578
             $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4033 4579
             $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4034 4580
             if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
@@ -4038,8 +4584,7 @@  discard block
 block discarded – undo
4038 4584
             $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4039 4585
           }
4040 4586
         }
4041
-      }
4042
-      else {
4587
+      } else {
4043 4588
         $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4044 4589
       }
4045 4590
     }
@@ -4061,8 +4606,7 @@  discard block
 block discarded – undo
4061 4606
         $content = $this->_createElement( 'extref', $attributes, null );
4062 4607
         $attributes = null;
4063 4608
       }
4064
-    }
4065
-    elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4609
+    } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4066 4610
       $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4067 4611
     }
4068 4612
     $output .= $attributes;
@@ -4106,30 +4650,30 @@  discard block
 block discarded – undo
4106 4650
     $CNattrExist = $LANGattrExist = FALSE;
4107 4651
     if( is_array( $params )) {
4108 4652
       foreach( $params as $paramKey => $paramValue ) {
4109
-        if( is_int( $paramKey ))
4110
-          $attr2            .= $this->intAttrDelimiter.$paramValue;
4111
-        elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4653
+        if( is_int( $paramKey )) {
4654
+                  $attr2            .= $this->intAttrDelimiter.$paramValue;
4655
+        } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4112 4656
           $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4113 4657
           $LANGattrExist     = TRUE;
4114
-        }
4115
-        elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4658
+        } elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4116 4659
           $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4117 4660
           $CNattrExist       = TRUE;
4661
+        } elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4662
+                  $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4663
+        } elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4664
+                  $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4665
+        } elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4666
+                  $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4667
+        } else {
4668
+                  $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4118 4669
         }
4119
-        elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4120
-          $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4121
-        elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4122
-          $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4123
-        elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4124
-          $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4125
-        else
4126
-          $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4127 4670
       }
4128 4671
     }
4129 4672
     if( !$LANGattrExist ) {
4130 4673
       $lang = $this->getConfig( 'language' );
4131
-      if(( $CNattrExist || $LANGattrKey ) && $lang )
4132
-        $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4674
+      if(( $CNattrExist || $LANGattrKey ) && $lang ) {
4675
+              $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4676
+      }
4133 4677
     }
4134 4678
     return $attrLANG.$attr1.$attr2;
4135 4679
   }
@@ -4143,47 +4687,57 @@  discard block
 block discarded – undo
4143 4687
  * @return array $params, property parameters
4144 4688
  */
4145 4689
   function _chkdatecfg( $theDate, & $parno, & $params ) {
4146
-    if( isset( $params['TZID'] ))
4147
-      $parno = 6;
4148
-    elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4149
-      $parno = 3;
4150
-    else {
4151
-      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4152
-        $parno = 7;
4690
+    if( isset( $params['TZID'] )) {
4691
+          $parno = 6;
4692
+    } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) {
4693
+          $parno = 3;
4694
+    } else {
4695
+      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) {
4696
+              $parno = 7;
4697
+      }
4153 4698
       if( is_array( $theDate )) {
4154
-        if( isset( $theDate['timestamp'] ))
4155
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4156
-        else
4157
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4699
+        if( isset( $theDate['timestamp'] )) {
4700
+                  $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4701
+        } else {
4702
+                  $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4703
+        }
4158 4704
         if( !empty( $tzid )) {
4159 4705
           $parno = 7;
4160
-          if( !$this->_isOffset( $tzid ))
4161
-            $params['TZID'] = $tzid; // save only timezone
4706
+          if( !$this->_isOffset( $tzid )) {
4707
+                      $params['TZID'] = $tzid;
4708
+          }
4709
+          // save only timezone
4710
+        } elseif( !$parno && ( 3 == count( $theDate )) && 
4711
+          ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) {
4712
+                  $parno = 3;
4713
+        } else {
4714
+                  $parno = 6;
4162 4715
         }
4163
-        elseif( !$parno && ( 3 == count( $theDate )) && 
4164
-          ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4165
-          $parno = 3;
4166
-        else
4167
-          $parno = 6;
4168
-      }
4169
-      else { // string
4716
+      } else { // string
4170 4717
         $date = trim( $theDate );
4171
-        if( 'Z' == substr( $date, -1 ))
4172
-          $parno = 7; // UTC DATE-TIME
4718
+        if( 'Z' == substr( $date, -1 )) {
4719
+                  $parno = 7;
4720
+        }
4721
+        // UTC DATE-TIME
4173 4722
         elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && 
4174
-          ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4175
-          $parno = 3; // DATE
4723
+          ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) {
4724
+                  $parno = 3;
4725
+        }
4726
+        // DATE
4176 4727
         $date = $this->_date_time_string( $date, $parno );
4177 4728
         if( !empty( $date['tz'] )) {
4178 4729
           $parno = 7;
4179
-          if( !$this->_isOffset( $date['tz'] ))
4180
-            $params['TZID'] = $date['tz']; // save only timezone
4730
+          if( !$this->_isOffset( $date['tz'] )) {
4731
+                      $params['TZID'] = $date['tz'];
4732
+          }
4733
+          // save only timezone
4734
+        } elseif( empty( $parno )) {
4735
+                  $parno = 6;
4181 4736
         }
4182
-        elseif( empty( $parno ))
4183
-          $parno = 6;
4184 4737
       }
4185
-      if( isset( $params['TZID'] ))
4186
-        $parno = 6;
4738
+      if( isset( $params['TZID'] )) {
4739
+              $parno = 6;
4740
+      }
4187 4741
     }
4188 4742
   }
4189 4743
 /**
@@ -4199,14 +4753,18 @@  discard block
 block discarded – undo
4199 4753
  */
4200 4754
   function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4201 4755
     if( !$startdate || !$enddate ) {
4202
-      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4203
-        return null;
4204
-      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4756
+      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) {
4757
+              return null;
4758
+      }
4759
+      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' ))) {
4760
+          // vevent/vfreebusy
4205 4761
         if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4206 4762
           return null;
4763
+      }
4764
+    }
4765
+    if( !$startdate || !$enddate ) {
4766
+          return null;
4207 4767
     }
4208
-    if( !$startdate || !$enddate )
4209
-      return null;
4210 4768
     $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4211 4769
     $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4212 4770
     $wduration   = $endWdate - $startWdate;
@@ -4232,15 +4790,23 @@  discard block
 block discarded – undo
4232 4790
  */
4233 4791
   function _date2timestamp( $datetime, $tz=null ) {
4234 4792
     $output = null;
4235
-    if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4236
-    if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4237
-    if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4793
+    if( !isset( $datetime['hour'] )) {
4794
+        $datetime['hour'] = '0';
4795
+    }
4796
+    if( !isset( $datetime['min'] )) {
4797
+        $datetime['min']  = '0';
4798
+    }
4799
+    if( !isset( $datetime['sec'] )) {
4800
+        $datetime['sec']  = '0';
4801
+    }
4238 4802
     foreach( $datetime as $dkey => $dvalue ) {
4239
-      if( 'tz' != $dkey )
4240
-        $datetime[$dkey] = (integer) $dvalue;
4803
+      if( 'tz' != $dkey ) {
4804
+              $datetime[$dkey] = (integer) $dvalue;
4805
+      }
4806
+    }
4807
+    if( $tz ) {
4808
+          $datetime['tz'] = $tz;
4241 4809
     }
4242
-    if( $tz )
4243
-      $datetime['tz'] = $tz;
4244 4810
     $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4245 4811
     $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4246 4812
     return $output;
@@ -4275,12 +4841,15 @@  discard block
 block discarded – undo
4275 4841
       }
4276 4842
     }
4277 4843
     if( 3 != $parno ) {
4278
-      if( !isset( $output['hour'] ))
4279
-        $output['hour'] = 0;
4280
-      if( !isset( $output['min']  ))
4281
-        $output['min'] = 0;
4282
-      if( !isset( $output['sec']  ))
4283
-        $output['sec'] = 0;
4844
+      if( !isset( $output['hour'] )) {
4845
+              $output['hour'] = 0;
4846
+      }
4847
+      if( !isset( $output['min']  )) {
4848
+              $output['min'] = 0;
4849
+      }
4850
+      if( !isset( $output['sec']  )) {
4851
+              $output['sec'] = 0;
4852
+      }
4284 4853
     }
4285 4854
     return $output;
4286 4855
   }
@@ -4300,39 +4869,37 @@  discard block
 block discarded – undo
4300 4869
     if( 'Z' == substr( $datetime, -1 )) {
4301 4870
       $tz = 'Z';
4302 4871
       $datetime = trim( substr( $datetime, 0, $len ));
4303
-    }
4304
-    elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4872
+    } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4305 4873
                   ( '-' == substr( $datetime, -3, 1 )) ||
4306 4874
                   ( ':' == substr( $datetime, -3, 1 )) ||
4307 4875
                   ( '.' == substr( $datetime, -3, 1 ))) {
4308 4876
       $continue = TRUE;
4309
-    }
4310
-    elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4877
+    } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4311 4878
             ( ' +' == substr( $datetime, -6, 2 )) ||
4312 4879
             ( ' -' == substr( $datetime, -6, 2 ))) {
4313 4880
       $tz = substr( $datetime, -5, 5 );
4314 4881
       $datetime = substr( $datetime, 0, ($len - 5));
4315
-    }
4316
-    elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4882
+    } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4317 4883
             ( ' +' == substr( $datetime, -8, 2 )) ||
4318 4884
             ( ' -' == substr( $datetime, -8, 2 ))) {
4319 4885
       $tz = substr( $datetime, -7, 7 );
4320 4886
       $datetime = substr( $datetime, 0, ($len - 7));
4321
-    }
4322
-    elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4887
+    } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4323 4888
       $continue = TRUE;
4324
-    }
4325
-    elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4889
+    } elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4326 4890
       $continue = TRUE;
4327
-    }
4328
-    else {
4891
+    } else {
4329 4892
       $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4330 4893
       for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4331
-        if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4332
-          break; // if exists, tz ends here.. . ?
4894
+        if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) {
4895
+                  break;
4896
+        }
4897
+        // if exists, tz ends here.. . ?
4333 4898
         elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4334
-             ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4335
-          $tx--; // tz length counter
4899
+             ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) {
4900
+                  $tx--;
4901
+        }
4902
+        // tz length counter
4336 4903
       }
4337 4904
       if( 0 > $tx ) {
4338 4905
         $tz = substr( $datetime, $tx );
@@ -4341,8 +4908,7 @@  discard block
 block discarded – undo
4341 4908
     }
4342 4909
     if( 0 < substr_count( $datetime, '-' )) {
4343 4910
       $datetime = str_replace( '-', '/', $datetime );
4344
-    }
4345
-    elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4911
+    } elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4346 4912
            ( 'T' ==      substr( $datetime, 8, 1 )) &&
4347 4913
             ctype_digit( substr( $datetime, 9, 6 ))) {
4348 4914
       $datetime = substr( $datetime,  4, 2 )
@@ -4362,10 +4928,10 @@  discard block
 block discarded – undo
4362 4928
       $output['hour']  = substr( $datestring, 11, 2 );
4363 4929
       $output['min']   = substr( $datestring, 14, 2 );
4364 4930
       $output['sec']   = substr( $datestring, 17, 2 );
4365
-      if( !empty( $tz ))
4366
-        $output['tz']  = $tz;
4367
-    }
4368
-    elseif( 3 != $parno ) {
4931
+      if( !empty( $tz )) {
4932
+              $output['tz']  = $tz;
4933
+      }
4934
+    } elseif( 3 != $parno ) {
4369 4935
       if(( '00' < substr( $datestring, 11, 2 )) ||
4370 4936
          ( '00' < substr( $datestring, 14, 2 )) ||
4371 4937
          ( '00' < substr( $datestring, 17, 2 ))) {
@@ -4373,8 +4939,9 @@  discard block
 block discarded – undo
4373 4939
         $output['min']   = substr( $datestring, 14, 2 );
4374 4940
         $output['sec']   = substr( $datestring, 17, 2 );
4375 4941
       }
4376
-      if( !empty( $tz ))
4377
-        $output['tz']  = $tz;
4942
+      if( !empty( $tz )) {
4943
+              $output['tz']  = $tz;
4944
+      }
4378 4945
     }
4379 4946
     return $output;
4380 4947
   }
@@ -4401,10 +4968,11 @@  discard block
 block discarded – undo
4401 4968
       $durseconds  =           $durseconds % ( 60 * 60 );
4402 4969
       $output['min']  = floor( $durseconds / ( 60 ));
4403 4970
       $output['sec']  =      ( $durseconds % ( 60 ));
4404
-    }
4405
-    else {
4971
+    } else {
4406 4972
       foreach( $duration as $durKey => $durValue ) {
4407
-        if( empty( $durValue )) continue;
4973
+        if( empty( $durValue )) {
4974
+            continue;
4975
+        }
4408 4976
         switch ( $durKey ) {
4409 4977
           case '0': case 'week': $output['week']  = $durValue; break;
4410 4978
           case '1': case 'day':  $output['day']   = $durValue; break;
@@ -4419,14 +4987,22 @@  discard block
 block discarded – undo
4419 4987
       return $output;
4420 4988
     }
4421 4989
     unset( $output['week'] );
4422
-    if( empty( $output['day'] ))
4423
-      unset( $output['day'] );
4990
+    if( empty( $output['day'] )) {
4991
+          unset( $output['day'] );
4992
+    }
4424 4993
     if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4425
-      if( !isset( $output['hour'] )) $output['hour'] = 0;
4426
-      if( !isset( $output['min']  )) $output['min']  = 0;
4427
-      if( !isset( $output['sec']  )) $output['sec']  = 0;
4428
-      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4429
-        unset( $output['hour'], $output['min'], $output['sec'] );
4994
+      if( !isset( $output['hour'] )) {
4995
+          $output['hour'] = 0;
4996
+      }
4997
+      if( !isset( $output['min']  )) {
4998
+          $output['min']  = 0;
4999
+      }
5000
+      if( !isset( $output['sec']  )) {
5001
+          $output['sec']  = 0;
5002
+      }
5003
+      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) {
5004
+              unset( $output['hour'], $output['min'], $output['sec'] );
5005
+      }
4430 5006
     }
4431 5007
     return $output;
4432 5008
   }
@@ -4443,28 +5019,32 @@  discard block
 block discarded – undo
4443 5019
     if( $startdate && $duration ) {
4444 5020
       $d1               = $startdate;
4445 5021
       $dur              = $duration;
4446
-    }
4447
-    elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
5022
+    } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4448 5023
       $d1               = $this->dtstart['value'];
4449 5024
       $dur              = $this->duration['value'];
5025
+    } else {
5026
+          return null;
4450 5027
     }
4451
-    else
4452
-      return null;
4453 5028
     $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4454 5029
     $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4455 5030
     $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4456 5031
     $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4457 5032
     $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4458
-    if( isset( $dur['week'] ))
4459
-      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4460
-    if( isset( $dur['day'] ))
4461
-      $dtend += ( $dur['day'] * 24 * 60 * 60 );
4462
-    if( isset( $dur['hour'] ))
4463
-      $dtend += ( $dur['hour'] * 60 *60 );
4464
-    if( isset( $dur['min'] ))
4465
-      $dtend += ( $dur['min'] * 60 );
4466
-    if( isset( $dur['sec'] ))
4467
-      $dtend +=   $dur['sec'];
5033
+    if( isset( $dur['week'] )) {
5034
+          $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
5035
+    }
5036
+    if( isset( $dur['day'] )) {
5037
+          $dtend += ( $dur['day'] * 24 * 60 * 60 );
5038
+    }
5039
+    if( isset( $dur['hour'] )) {
5040
+          $dtend += ( $dur['hour'] * 60 *60 );
5041
+    }
5042
+    if( isset( $dur['min'] )) {
5043
+          $dtend += ( $dur['min'] * 60 );
5044
+    }
5045
+    if( isset( $dur['sec'] )) {
5046
+          $dtend +=   $dur['sec'];
5047
+    }
4468 5048
     $dtend2 = array();
4469 5049
     $dtend2['year']   = date('Y', $dtend );
4470 5050
     $dtend2['month']  = date('m', $dtend );
@@ -4472,10 +5052,12 @@  discard block
 block discarded – undo
4472 5052
     $dtend2['hour']   = date('H', $dtend );
4473 5053
     $dtend2['min']    = date('i', $dtend );
4474 5054
     $dtend2['sec']    = date('s', $dtend );
4475
-    if( isset( $d1['tz'] ))
4476
-      $dtend2['tz']   = $d1['tz'];
4477
-    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4478
-      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5055
+    if( isset( $d1['tz'] )) {
5056
+          $dtend2['tz']   = $d1['tz'];
5057
+    }
5058
+    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) {
5059
+          unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5060
+    }
4479 5061
     return $dtend2;
4480 5062
   }
4481 5063
 /**
@@ -4489,10 +5071,12 @@  discard block
 block discarded – undo
4489 5071
   function _duration_string( $duration ) {
4490 5072
    $duration = (string) trim( $duration );
4491 5073
    while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4492
-     if( 0 < strlen( $duration ))
4493
-       $duration = substr( $duration, 1 );
4494
-     else
4495
-       return false; // no leading P !?!?
5074
+     if( 0 < strlen( $duration )) {
5075
+            $duration = substr( $duration, 1 );
5076
+     } else {
5077
+            return false;
5078
+     }
5079
+     // no leading P !?!?
4496 5080
    }
4497 5081
    $duration = substr( $duration, 1 ); // skip P
4498 5082
    $duration = str_replace ( 't', 'T', $duration );
@@ -4522,10 +5106,13 @@  discard block
 block discarded – undo
4522 5106
         $val            = null;
4523 5107
         break;
4524 5108
       default:
4525
-        if( !ctype_digit( $duration{$ix} ))
4526
-          return false; // unknown duration controll character  !?!?
4527
-        else
4528
-          $val .= $duration{$ix};
5109
+        if( !ctype_digit( $duration{$ix} )) {
5110
+                  return false;
5111
+        }
5112
+        // unknown duration controll character  !?!?
5113
+        else {
5114
+                  $val .= $duration{$ix};
5115
+        }
4529 5116
      }
4530 5117
    }
4531 5118
    return $this->_duration_array( $output );
@@ -4544,10 +5131,12 @@  discard block
 block discarded – undo
4544 5131
  * @return int
4545 5132
  */
4546 5133
   function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4547
-    if( $preSet )
4548
-      return $preSet;
4549
-    if( !is_array( $array ) || ( 0 == count( $array )))
4550
-      return $elseVal;
5134
+    if( $preSet ) {
5135
+          return $preSet;
5136
+    }
5137
+    if( !is_array( $array ) || ( 0 == count( $array ))) {
5138
+          return $elseVal;
5139
+    }
4551 5140
     foreach( $array as $key => $value ) {
4552 5141
       if( strtoupper( $expkey ) == strtoupper( $key )) {
4553 5142
         if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
@@ -4573,13 +5162,15 @@  discard block
 block discarded – undo
4573 5162
         !isset( $datetime['day'] )   &&
4574 5163
         !isset( $datetime['hour'] )  &&
4575 5164
         !isset( $datetime['min'] )   &&
4576
-        !isset( $datetime['sec'] ))
4577
-      return ;
5165
+        !isset( $datetime['sec'] )) {
5166
+          return ;
5167
+    }
4578 5168
     $output = null;
4579 5169
     // 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"; }
4580 5170
     foreach( $datetime as $dkey => $dvalue ) {
4581
-      if( 'tz' != $dkey )
4582
-        $datetime[$dkey] = (integer) $dvalue;
5171
+      if( 'tz' != $dkey ) {
5172
+              $datetime[$dkey] = (integer) $dvalue;
5173
+      }
4583 5174
     }
4584 5175
     $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
4585 5176
     if( isset( $datetime['hour'] )  ||
@@ -4587,29 +5178,33 @@  discard block
 block discarded – undo
4587 5178
         isset( $datetime['sec'] )   ||
4588 5179
         isset( $datetime['tz'] )) {
4589 5180
       if( isset( $datetime['tz'] )  &&
4590
-         !isset( $datetime['hour'] ))
4591
-        $datetime['hour'] = 0;
5181
+         !isset( $datetime['hour'] )) {
5182
+              $datetime['hour'] = 0;
5183
+      }
4592 5184
       if( isset( $datetime['hour'] )  &&
4593
-         !isset( $datetime['min'] ))
4594
-        $datetime['min'] = 0;
5185
+         !isset( $datetime['min'] )) {
5186
+              $datetime['min'] = 0;
5187
+      }
4595 5188
       if( isset( $datetime['hour'] )  &&
4596 5189
           isset( $datetime['min'] )   &&
4597
-         !isset( $datetime['sec'] ))
4598
-        $datetime['sec'] = 0;
5190
+         !isset( $datetime['sec'] )) {
5191
+              $datetime['sec'] = 0;
5192
+      }
4599 5193
       $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600 5194
       $output .= date('\THis', $date );
4601 5195
       if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4602 5196
         $datetime['tz'] = trim( $datetime['tz'] );
4603
-        if( 'Z' == $datetime['tz'] )
4604
-          $output .= 'Z';
5197
+        if( 'Z' == $datetime['tz'] ) {
5198
+                  $output .= 'Z';
5199
+        }
4605 5200
         $offset = $this->_tz2offset( $datetime['tz'] );
4606 5201
         if( 0 != $offset ) {
4607 5202
           $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608 5203
           $output    = date( 'Ymd\THis\Z', $date );
4609 5204
         }
5205
+      } elseif( 7 == $parno ) {
5206
+              $output .= 'Z';
4610 5207
       }
4611
-      elseif( 7 == $parno )
4612
-        $output .= 'Z';
4613 5208
     }
4614 5209
     return $output;
4615 5210
   }
@@ -4626,14 +5221,16 @@  discard block
 block discarded – undo
4626 5221
         !isset( $duration['day'] )  &&
4627 5222
         !isset( $duration['hour'] ) &&
4628 5223
         !isset( $duration['min'] )  &&
4629
-        !isset( $duration['sec'] ))
4630
-      return;
5224
+        !isset( $duration['sec'] )) {
5225
+          return;
5226
+    }
4631 5227
     $output = 'P';
4632
-    if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4633
-      $output   .= $duration['week'].'W';
4634
-    else {
4635
-      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4636
-        $output .= $duration['day'].'D';
5228
+    if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) {
5229
+          $output   .= $duration['week'].'W';
5230
+    } else {
5231
+      if( isset($duration['day'] ) && ( 0 < $duration['day'] )) {
5232
+              $output .= $duration['day'].'D';
5233
+      }
4637 5234
       if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4638 5235
          ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4639 5236
          ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
@@ -4658,7 +5255,9 @@  discard block
 block discarded – undo
4658 5255
     $output = null;
4659 5256
     foreach( $recurdata as $therule ) {
4660 5257
       if( empty( $therule['value'] )) {
4661
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
5258
+        if( $this->getConfig( 'allowEmpty' )) {
5259
+            $output .= $this->_createElement( $recurlabel );
5260
+        }
4662 5261
         continue;
4663 5262
       }
4664 5263
       $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
@@ -4694,9 +5293,9 @@  discard block
 block discarded – undo
4694 5293
                 $content2 .= ( $vix ) ? ',' : null;
4695 5294
                 $content2 .= $valuePart;
4696 5295
               }
5296
+            } else {
5297
+                         $content2 .= $rulevalue;
4697 5298
             }
4698
-            else
4699
-             $content2 .= $rulevalue;
4700 5299
             break;
4701 5300
           }
4702 5301
           case 'BYDAY': {
@@ -4707,19 +5306,19 @@  discard block
 block discarded – undo
4707 5306
               if( is_array( $valuePart )) {
4708 5307
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4709 5308
                 foreach( $valuePart as $vix2 => $valuePart2 ) {
4710
-                  if( 'DAY' != strtoupper( $vix2 ))
4711
-                      $content21 .= $valuePart2;
4712
-                  else
4713
-                    $content22 .= $valuePart2;
5309
+                  if( 'DAY' != strtoupper( $vix2 )) {
5310
+                                        $content21 .= $valuePart2;
5311
+                  } else {
5312
+                                      $content22 .= $valuePart2;
5313
+                  }
4714 5314
                 }
4715 5315
                 $content2 .= $content21.$content22;
4716 5316
                 $bydaycnt++;
4717
-              }
4718
-              else {
5317
+              } else {
4719 5318
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4720
-                if( 'DAY' != strtoupper( $vix ))
4721
-                    $content21 .= $valuePart;
4722
-                else {
5319
+                if( 'DAY' != strtoupper( $vix )) {
5320
+                                    $content21 .= $valuePart;
5321
+                } else {
4723 5322
                   $content22 .= $valuePart;
4724 5323
                   $bydaycnt++;
4725 5324
                 }
@@ -4765,24 +5364,32 @@  discard block
 block discarded – undo
4765 5364
  * @return bool
4766 5365
  */
4767 5366
   function _isArrayDate( $input ) {
4768
-    if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4769
-      return FALSE;
4770
-    if( 7 == count( $input ))
4771
-      return TRUE;
4772
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4773
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4774
-    if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4775
-      return FALSE;
4776
-    if( in_array( 0, $input ))
4777
-      return FALSE;
4778
-    if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4779
-      return FALSE;
5367
+    if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) {
5368
+          return FALSE;
5369
+    }
5370
+    if( 7 == count( $input )) {
5371
+          return TRUE;
5372
+    }
5373
+    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5374
+          return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5375
+    }
5376
+    if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) {
5377
+          return FALSE;
5378
+    }
5379
+    if( in_array( 0, $input )) {
5380
+          return FALSE;
5381
+    }
5382
+    if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) {
5383
+          return FALSE;
5384
+    }
4780 5385
     if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4781
-         checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4782
-      return TRUE;
5386
+         checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) {
5387
+          return TRUE;
5388
+    }
4783 5389
     $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4784
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4785
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5390
+    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5391
+          return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5392
+    }
4786 5393
     return FALSE;
4787 5394
   }
4788 5395
 /**
@@ -4806,16 +5413,17 @@  discard block
 block discarded – undo
4806 5413
  */
4807 5414
   function _isOffset( $input ) {
4808 5415
     $input         = trim( (string) $input );
4809
-    if( 'Z' == substr( $input, -1 ))
4810
-      return TRUE;
4811
-    elseif((   5 <= strlen( $input )) &&
5416
+    if( 'Z' == substr( $input, -1 )) {
5417
+          return TRUE;
5418
+    } elseif((   5 <= strlen( $input )) &&
4812 5419
        ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4813
-       (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4814
-      return TRUE;
4815
-    elseif((    7 <= strlen( $input )) &&
5420
+       (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 ))) {
5421
+          return TRUE;
5422
+    } elseif((    7 <= strlen( $input )) &&
4816 5423
        ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4817
-       ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4818
-      return TRUE;
5424
+       ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) {
5425
+          return TRUE;
5426
+    }
4819 5427
     return FALSE;
4820 5428
 
4821 5429
   }
@@ -4828,14 +5436,29 @@  discard block
 block discarded – undo
4828 5436
  * @return bool
4829 5437
  */
4830 5438
   function _notExistProp( $propName ) {
4831
-    if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
5439
+    if( empty( $propName )) {
5440
+        return FALSE;
5441
+    }
5442
+    // when deleting x-prop, an empty propName may be used=allowed
4832 5443
     $propName = strtolower( $propName );
4833
-    if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
4834
-    elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) return TRUE; }
4835
-    elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid ))    return TRUE; }
4836
-    elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto ))       return TRUE; }
4837
-    elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4838
-    elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
5444
+    if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified )) {
5445
+        return TRUE;
5446
+    }
5447
+    } elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) {
5448
+        return TRUE;
5449
+    }
5450
+    } elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid )) {
5451
+        return TRUE;
5452
+    }
5453
+    } elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto )) {
5454
+        return TRUE;
5455
+    }
5456
+    } elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus )) {
5457
+        return TRUE;
5458
+    }
5459
+    } elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName )) {
5460
+        return TRUE;
5461
+    }
4839 5462
     return FALSE;
4840 5463
   }
4841 5464
 /**
@@ -4854,7 +5477,9 @@  discard block
 block discarded – undo
4854 5477
  * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4855 5478
  */
4856 5479
   function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4857
-    foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5480
+    foreach( $wdate as $k => $v ) {
5481
+        if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5482
+    }
4858 5483
     $wdatets     = $this->_date2timestamp( $wdate );
4859 5484
     $startdatets = $this->_date2timestamp( $startdate );
4860 5485
     if( !$enddate ) {
@@ -4863,43 +5488,54 @@  discard block
 block discarded – undo
4863 5488
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4864 5489
     }
4865 5490
     $endDatets = $this->_date2timestamp( $enddate ); // fix break
4866
-    if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4867
-      $recur['UNTIL'] = $enddate; // create break
5491
+    if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) {
5492
+          $recur['UNTIL'] = $enddate;
5493
+    }
5494
+    // create break
4868 5495
     if( isset( $recur['UNTIL'] )) {
4869 5496
       $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4870 5497
       if( $endDatets > $tdatets ) {
4871 5498
         $endDatets = $tdatets; // emergency break
4872 5499
         $enddate   = $this->_timestamp2date( $endDatets, 6 );
5500
+      } else {
5501
+              $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4873 5502
       }
4874
-      else
4875
-        $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4876 5503
     }
4877 5504
     if( $wdatets > $endDatets ) {
4878 5505
      //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4879 5506
       return array(); // nothing to do.. .
4880 5507
     }
4881
-    if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4882
-      $recur['FREQ'] = 'DAILY'; // ??
5508
+    if( !isset( $recur['FREQ'] )) {
5509
+        // "MUST be specified.. ."
5510
+      $recur['FREQ'] = 'DAILY';
5511
+    }
5512
+    // ??
4883 5513
     $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4884
-    if( !isset( $recur['INTERVAL'] ))
4885
-      $recur['INTERVAL'] = 1;
5514
+    if( !isset( $recur['INTERVAL'] )) {
5515
+          $recur['INTERVAL'] = 1;
5516
+    }
4886 5517
     $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4887 5518
             /* find out how to step up dates and set index for interval count */
4888 5519
     $step = array();
4889
-    if( 'YEARLY' == $recur['FREQ'] )
4890
-      $step['year']  = 1;
4891
-    elseif( 'MONTHLY' == $recur['FREQ'] )
4892
-      $step['month'] = 1;
4893
-    elseif( 'WEEKLY' == $recur['FREQ'] )
4894
-      $step['day']   = 7;
4895
-    else
4896
-      $step['day']   = 1;
4897
-    if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4898
-      $step = array( 'month' => 1 );
4899
-    if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
5520
+    if( 'YEARLY' == $recur['FREQ'] ) {
5521
+          $step['year']  = 1;
5522
+    } elseif( 'MONTHLY' == $recur['FREQ'] ) {
5523
+          $step['month'] = 1;
5524
+    } elseif( 'WEEKLY' == $recur['FREQ'] ) {
5525
+          $step['day']   = 7;
5526
+    } else {
5527
+          $step['day']   = 1;
5528
+    }
5529
+    if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) {
5530
+          $step = array( 'month' => 1 );
5531
+    }
5532
+    if( empty( $step ) && isset( $recur['BYWEEKNO'] )) {
5533
+        // ??
4900 5534
       $step = array( 'day' => 7 );
4901
-    if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4902
-      $step = array( 'day' => 1 );
5535
+    }
5536
+    if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) {
5537
+          $step = array( 'day' => 1 );
5538
+    }
4903 5539
     $intervalarr = array();
4904 5540
     if( 1 < $recur['INTERVAL'] ) {
4905 5541
       $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
@@ -4912,11 +5548,12 @@  discard block
 block discarded – undo
4912 5548
       $bysetposMold = $wdate['month'];
4913 5549
       $bysetposDold = $wdate['day'];
4914 5550
       if( is_array( $recur['BYSETPOS'] )) {
4915
-        foreach( $recur['BYSETPOS'] as $bix => $bval )
4916
-          $recur['BYSETPOS'][$bix] = (int) $bval;
5551
+        foreach( $recur['BYSETPOS'] as $bix => $bval ) {
5552
+                  $recur['BYSETPOS'][$bix] = (int) $bval;
5553
+        }
5554
+      } else {
5555
+              $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4917 5556
       }
4918
-      else
4919
-        $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4920 5557
       $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4921 5558
     }
4922 5559
     $this->_stepdate( $wdate, $wdatets, $step);
@@ -4925,10 +5562,12 @@  discard block
 block discarded – undo
4925 5562
              /* MAIN LOOP */
4926 5563
      // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4927 5564
     while( TRUE ) {
4928
-      if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4929
-        break;
4930
-      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4931
-        break;
5565
+      if( isset( $endDatets ) && ( $wdatets > $endDatets )) {
5566
+              break;
5567
+      }
5568
+      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5569
+              break;
5570
+      }
4932 5571
       if( $year_old != $wdate['year'] ) {
4933 5572
         $year_old   = $wdate['year'];
4934 5573
         $daycnts    = array();
@@ -4937,8 +5576,9 @@  discard block
 block discarded – undo
4937 5576
         for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4938 5577
           $daycnts[$m] = array();
4939 5578
           $weekdaycnt = array();
4940
-          foreach( $daynames as $dn )
4941
-            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5579
+          foreach( $daynames as $dn ) {
5580
+                      $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5581
+          }
4942 5582
           $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4943 5583
           for( $d   = 1; $d <= $mcnt; $d++ ) {
4944 5584
             $daycnts[$m][$d] = array();
@@ -4955,8 +5595,9 @@  discard block
 block discarded – undo
4955 5595
               $yeardaycnt[$day]++;
4956 5596
               $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4957 5597
             }
4958
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4959
-              $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5598
+            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5599
+                          $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5600
+            }
4960 5601
           }
4961 5602
         }
4962 5603
         $daycnt = 0;
@@ -4964,9 +5605,9 @@  discard block
 block discarded – undo
4964 5605
         if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4965 5606
           $weekno = null;
4966 5607
           for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4967
-            if( !$weekno )
4968
-              $weekno = $daycnts[12][$d]['weekno_up'];
4969
-            elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
5608
+            if( !$weekno ) {
5609
+                          $weekno = $daycnts[12][$d]['weekno_up'];
5610
+            } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
4970 5611
               $weekno = $daycnts[12][$d]['weekno_up'];
4971 5612
               break;
4972 5613
             }
@@ -4974,8 +5615,9 @@  discard block
 block discarded – undo
4974 5615
         }
4975 5616
         for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
4976 5617
           $weekdaycnt = array();
4977
-          foreach( $daynames as $dn )
4978
-            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5618
+          foreach( $daynames as $dn ) {
5619
+                      $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5620
+          }
4979 5621
           $monthcnt = 0;
4980 5622
           $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4981 5623
           for( $d   = $mcnt; $d > 0; $d-- ) {
@@ -4994,8 +5636,9 @@  discard block
 block discarded – undo
4994 5636
               $yeardaycnt[$day] -= 1;
4995 5637
               $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4996 5638
             }
4997
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4998
-              $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5639
+            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5640
+                          $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5641
+            }
4999 5642
           }
5000 5643
         }
5001 5644
       }
@@ -5006,36 +5649,42 @@  discard block
 block discarded – undo
5006 5649
             /* check interval */
5007 5650
         $currentKey = array_keys( $intervalarr );
5008 5651
         $currentKey = end( $currentKey ); // get last index
5009
-        if( $currentKey != $intervalix )
5010
-          $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5652
+        if( $currentKey != $intervalix ) {
5653
+                  $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5654
+        }
5011 5655
         if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5012 5656
            ( 0 != $intervalarr[$intervalix] )) {
5013 5657
             /* step up date */
5014 5658
     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5015 5659
           $this->_stepdate( $wdate, $wdatets, $step);
5016 5660
           continue;
5017
-        }
5018
-        else // continue within the selected interval
5661
+        } else {
5662
+            // continue within the selected interval
5019 5663
           $intervalarr[$intervalix] = 0;
5664
+        }
5020 5665
    //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5021 5666
       }
5022 5667
       $updateOK = TRUE;
5023
-      if( $updateOK && isset( $recur['BYMONTH'] ))
5024
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5668
+      if( $updateOK && isset( $recur['BYMONTH'] )) {
5669
+              $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5025 5670
                                            , $wdate['month']
5026 5671
                                            ,($wdate['month'] - 13));
5027
-      if( $updateOK && isset( $recur['BYWEEKNO'] ))
5028
-        $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5672
+      }
5673
+      if( $updateOK && isset( $recur['BYWEEKNO'] )) {
5674
+              $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5029 5675
                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5030 5676
                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5031
-      if( $updateOK && isset( $recur['BYYEARDAY'] ))
5032
-        $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5677
+      }
5678
+      if( $updateOK && isset( $recur['BYYEARDAY'] )) {
5679
+              $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5033 5680
                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5034 5681
                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5035
-      if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5036
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5682
+      }
5683
+      if( $updateOK && isset( $recur['BYMONTHDAY'] )) {
5684
+              $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5037 5685
                                            , $wdate['day']
5038 5686
                                            , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5687
+      }
5039 5688
     //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5040 5689
       if( $updateOK && isset( $recur['BYDAY'] )) {
5041 5690
         $updateOK = FALSE;
@@ -5043,42 +5692,45 @@  discard block
 block discarded – undo
5043 5692
         $d = $wdate['day'];
5044 5693
         if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5045 5694
           $daynoexists = $daynosw = $daynamesw =  FALSE;
5046
-          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5047
-            $daynamesw = TRUE;
5695
+          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) {
5696
+                      $daynamesw = TRUE;
5697
+          }
5048 5698
           if( isset( $recur['BYDAY'][0] )) {
5049 5699
             $daynoexists = TRUE;
5050
-            if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5051
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5700
+            if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) {
5701
+                          $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5052 5702
                                                 , $daycnts[$m][$d]['monthdayno_up']
5053 5703
                                                 , $daycnts[$m][$d]['monthdayno_down'] );
5054
-            elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5055
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5704
+            } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5705
+                          $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5056 5706
                                                 , $daycnts[$m][$d]['yeardayno_up']
5057 5707
                                                 , $daycnts[$m][$d]['yeardayno_down'] );
5708
+            }
5058 5709
           }
5059 5710
           if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5060 5711
              ( !$daynoexists && !$daynosw && $daynamesw )) {
5061 5712
             $updateOK = TRUE;
5062 5713
           }
5063 5714
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5064
-        }
5065
-        else {
5715
+        } else {
5066 5716
           foreach( $recur['BYDAY'] as $bydayvalue ) {
5067 5717
             $daynoexists = $daynosw = $daynamesw = FALSE;
5068 5718
             if( isset( $bydayvalue['DAY'] ) &&
5069
-                     ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5070
-              $daynamesw = TRUE;
5719
+                     ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) {
5720
+                          $daynamesw = TRUE;
5721
+            }
5071 5722
             if( isset( $bydayvalue[0] )) {
5072 5723
               $daynoexists = TRUE;
5073 5724
               if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5074
-                   isset( $recur['BYMONTH'] ))
5075
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5725
+                   isset( $recur['BYMONTH'] )) {
5726
+                              $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5076 5727
                                                   , $daycnts[$m][$d]['monthdayno_up']
5077 5728
                                                   , $daycnts[$m][$d]['monthdayno_down'] );
5078
-              elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5079
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5729
+              } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5730
+                              $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5080 5731
                                                   , $daycnts[$m][$d]['yeardayno_up']
5081 5732
                                                   , $daycnts[$m][$d]['yeardayno_down'] );
5733
+              }
5082 5734
             }
5083 5735
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5084 5736
             if((  $daynoexists &&  $daynosw && $daynamesw ) ||
@@ -5095,12 +5747,12 @@  discard block
 block discarded – undo
5095 5747
         if( isset( $recur['BYSETPOS'] ) &&
5096 5748
           ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5097 5749
           if( isset( $recur['WEEKLY'] )) {
5098
-            if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5099
-              $bysetposw1[] = $wdatets;
5100
-            else
5101
-              $bysetposw2[] = $wdatets;
5102
-          }
5103
-          else {
5750
+            if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) {
5751
+                          $bysetposw1[] = $wdatets;
5752
+            } else {
5753
+                          $bysetposw2[] = $wdatets;
5754
+            }
5755
+          } else {
5104 5756
             if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5105 5757
                                             ( $bysetposYold == $wdate['year'] ))   ||
5106 5758
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
@@ -5109,13 +5761,13 @@  discard block
 block discarded – undo
5109 5761
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
5110 5762
                                            (( $bysetposYold == $wdate['year'] )  &&
5111 5763
                                             ( $bysetposMold == $wdate['month'])  &&
5112
-                                            ( $bysetposDold == $wdate['sday'] ))))
5113
-              $bysetposymd1[] = $wdatets;
5114
-            else
5115
-              $bysetposymd2[] = $wdatets;
5764
+                                            ( $bysetposDold == $wdate['sday'] )))) {
5765
+                          $bysetposymd1[] = $wdatets;
5766
+            } else {
5767
+                          $bysetposymd2[] = $wdatets;
5768
+            }
5116 5769
           }
5117
-        }
5118
-        else {
5770
+        } else {
5119 5771
             /* update result array if BYSETPOS is set */
5120 5772
           $countcnt++;
5121 5773
           if( $startdatets <= $wdatets ) { // only output within period
@@ -5135,21 +5787,18 @@  discard block
 block discarded – undo
5135 5787
           ( $bysetposYold != $wdate['year'] )) {
5136 5788
           $bysetpos     = TRUE;
5137 5789
           $bysetposYold = $wdate['year'];
5138
-        }
5139
-        elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5790
+        } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5140 5791
          (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5141 5792
           $bysetpos     = TRUE;
5142 5793
           $bysetposYold = $wdate['year'];
5143 5794
           $bysetposMold = $wdate['month'];
5144
-        }
5145
-        elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5795
+        } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5146 5796
           $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147 5797
           if( $bysetposWold != $weekno ) {
5148 5798
             $bysetposWold = $weekno;
5149 5799
             $bysetpos     = TRUE;
5150 5800
           }
5151
-        }
5152
-        elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5801
+        } elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5153 5802
          (( $bysetposYold != $wdate['year'] )  ||
5154 5803
           ( $bysetposMold != $wdate['month'] ) ||
5155 5804
           ( $bysetposDold != $wdate['sday'] ))) {
@@ -5162,14 +5811,15 @@  discard block
 block discarded – undo
5162 5811
           if( isset( $recur['BYWEEKNO'] )) {
5163 5812
             $bysetposarr1 = & $bysetposw1;
5164 5813
             $bysetposarr2 = & $bysetposw2;
5165
-          }
5166
-          else {
5814
+          } else {
5167 5815
             $bysetposarr1 = & $bysetposymd1;
5168 5816
             $bysetposarr2 = & $bysetposymd2;
5169 5817
           }
5170 5818
           foreach( $recur['BYSETPOS'] as $ix ) {
5171
-            if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5819
+            if( 0 > $ix ) {
5820
+                // both positive and negative BYSETPOS allowed
5172 5821
               $ix = ( count( $bysetposarr1 ) + $ix + 1);
5822
+            }
5173 5823
             $ix--;
5174 5824
             if( isset( $bysetposarr1[$ix] )) {
5175 5825
               if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
@@ -5178,8 +5828,9 @@  discard block
 block discarded – undo
5178 5828
               }
5179 5829
               $countcnt++;
5180 5830
             }
5181
-            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5182
-              break;
5831
+            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5832
+                          break;
5833
+            }
5183 5834
           }
5184 5835
           $bysetposarr1 = $bysetposarr2;
5185 5836
           $bysetposarr2 = array();
@@ -5189,12 +5840,13 @@  discard block
 block discarded – undo
5189 5840
   }
5190 5841
   function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5191 5842
     if( is_array( $BYvalue ) &&
5192
-      ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5193
-      return TRUE;
5194
-    elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5195
-      return TRUE;
5196
-    else
5197
-      return FALSE;
5843
+      ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) {
5844
+          return TRUE;
5845
+    } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) {
5846
+          return TRUE;
5847
+    } else {
5848
+          return FALSE;
5849
+    }
5198 5850
   }
5199 5851
   function _recurIntervalIx( $freq, $date, $wkst ) {
5200 5852
             /* create interval index */
@@ -5226,21 +5878,27 @@  discard block
 block discarded – undo
5226 5878
  */
5227 5879
   function _setRexrule( $rexrule ) {
5228 5880
     $input          = array();
5229
-    if( empty( $rexrule ))
5230
-      return $input;
5881
+    if( empty( $rexrule )) {
5882
+          return $input;
5883
+    }
5231 5884
     foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5232 5885
       $rexrulelabel = strtoupper( $rexrulelabel );
5233
-      if( 'UNTIL'  != $rexrulelabel )
5234
-        $input[$rexrulelabel]   = $rexrulevalue;
5235
-      else {
5236
-        if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5886
+      if( 'UNTIL'  != $rexrulelabel ) {
5887
+              $input[$rexrulelabel]   = $rexrulevalue;
5888
+      } else {
5889
+        if( $this->_isArrayTimestampDate( $rexrulevalue )) {
5890
+            // timestamp date
5237 5891
           $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5238
-        elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5892
+        } elseif( $this->_isArrayDate( $rexrulevalue )) {
5893
+            // date-time
5239 5894
           $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5240
-        elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5895
+        } elseif( 8 <= strlen( trim( $rexrulevalue ))) {
5896
+            // ex. 2006-08-03 10:12:18
5241 5897
           $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5242
-        if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5243
-          $input[$rexrulelabel]['tz'] = 'Z';
5898
+        }
5899
+        if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) {
5900
+                  $input[$rexrulelabel]['tz'] = 'Z';
5901
+        }
5244 5902
       }
5245 5903
     }
5246 5904
     return $input;
@@ -5264,7 +5922,9 @@  discard block
 block discarded – undo
5264 5922
     $input = $parno = null;
5265 5923
     $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5266 5924
     if( $this->_isArrayDate( $year )) {
5267
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5925
+      if( $localtime ) {
5926
+          unset ( $month['VALUE'], $month['TZID'] );
5927
+      }
5268 5928
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5269 5929
       if( isset( $input['params']['TZID'] )) {
5270 5930
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5274,9 +5934,10 @@  discard block
 block discarded – undo
5274 5934
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5275 5935
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5276 5936
       $input['value']  = $this->_date_time_array( $year, $parno );
5277
-    }
5278
-    elseif( $this->_isArrayTimestampDate( $year )) {
5279
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5937
+    } elseif( $this->_isArrayTimestampDate( $year )) {
5938
+      if( $localtime ) {
5939
+          unset ( $month['VALUE'], $month['TZID'] );
5940
+      }
5280 5941
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5281 5942
       if( isset( $input['params']['TZID'] )) {
5282 5943
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5286,9 +5947,10 @@  discard block
 block discarded – undo
5286 5947
       $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5287 5948
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5288 5949
       $input['value']  = $this->_timestamp2date( $year, $parno );
5289
-    }
5290
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5291
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5950
+    } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5951
+      if( $localtime ) {
5952
+          unset ( $month['VALUE'], $month['TZID'] );
5953
+      }
5292 5954
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5293 5955
       if( isset( $input['params']['TZID'] )) {
5294 5956
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5297,17 +5959,16 @@  discard block
 block discarded – undo
5297 5959
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5298 5960
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5299 5961
       $input['value']  = $this->_date_time_string( $year, $parno );
5300
-    }
5301
-    else {
5962
+    } else {
5302 5963
       if( is_array( $params )) {
5303
-        if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5964
+        if( $localtime ) {
5965
+            unset ( $params['VALUE'], $params['TZID'] );
5966
+        }
5304 5967
         $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5305
-      }
5306
-      elseif( is_array( $tz )) {
5968
+      } elseif( is_array( $tz )) {
5307 5969
         $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5308 5970
         $tz = FALSE;
5309
-      }
5310
-      elseif( is_array( $hour )) {
5971
+      } elseif( is_array( $hour )) {
5311 5972
         $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5312 5973
         $hour = $min = $sec = $tz = FALSE;
5313 5974
       }
@@ -5323,23 +5984,28 @@  discard block
 block discarded – undo
5323 5984
         $input['value']['hour'] = ( $hour ) ? $hour : '0';
5324 5985
         $input['value']['min']  = ( $min )  ? $min  : '0';
5325 5986
         $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5326
-        if( !empty( $tz ))
5327
-          $input['value']['tz'] = $tz;
5987
+        if( !empty( $tz )) {
5988
+                  $input['value']['tz'] = $tz;
5989
+        }
5328 5990
       }
5329 5991
     }
5330 5992
     if( 3 == $parno ) {
5331 5993
       $input['params']['VALUE'] = 'DATE';
5332 5994
       unset( $input['value']['tz'] );
5333 5995
       unset( $input['params']['TZID'] );
5996
+    } elseif( isset( $input['params']['TZID'] )) {
5997
+          unset( $input['value']['tz'] );
5998
+    }
5999
+    if( $localtime ) {
6000
+        unset( $input['value']['tz'], $input['params']['TZID'] );
6001
+    }
6002
+    if( isset( $input['value']['tz'] )) {
6003
+          $input['value']['tz'] = (string) $input['value']['tz'];
5334 6004
     }
5335
-    elseif( isset( $input['params']['TZID'] ))
5336
-      unset( $input['value']['tz'] );
5337
-    if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5338
-    if( isset( $input['value']['tz'] ))
5339
-      $input['value']['tz'] = (string) $input['value']['tz'];
5340 6005
     if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5341
-      ( !$this->_isOffset( $input['value']['tz'] )))
5342
-      $input['params']['TZID'] = $input['value']['tz'];
6006
+      ( !$this->_isOffset( $input['value']['tz'] ))) {
6007
+          $input['params']['TZID'] = $input['value']['tz'];
6008
+    }
5343 6009
     return $input;
5344 6010
   }
5345 6011
 /**
@@ -5361,16 +6027,13 @@  discard block
 block discarded – undo
5361 6027
     if( $this->_isArrayDate( $year )) {
5362 6028
       $input['value']  = $this->_date_time_array( $year, 7 );
5363 6029
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5364
-    }
5365
-    elseif( $this->_isArrayTimestampDate( $year )) {
6030
+    } elseif( $this->_isArrayTimestampDate( $year )) {
5366 6031
       $input['value']  = $this->_timestamp2date( $year, 7 );
5367 6032
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5368
-    }
5369
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
6033
+    } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5370 6034
       $input['value']  = $this->_date_time_string( $year, 7 );
5371 6035
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5372
-    }
5373
-    else {
6036
+    } else {
5374 6037
       $input['value']  = array( 'year'  => $year
5375 6038
                               , 'month' => $month
5376 6039
                               , 'day'   => $day
@@ -5380,14 +6043,18 @@  discard block
 block discarded – undo
5380 6043
       $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5381 6044
     }
5382 6045
     $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5383
-    if( !isset( $input['value']['hour'] ))
5384
-      $input['value']['hour'] = 0;
5385
-    if( !isset( $input['value']['min'] ))
5386
-      $input['value']['min'] = 0;
5387
-    if( !isset( $input['value']['sec'] ))
5388
-      $input['value']['sec'] = 0;
5389
-    if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5390
-      $input['value']['tz'] = 'Z';
6046
+    if( !isset( $input['value']['hour'] )) {
6047
+          $input['value']['hour'] = 0;
6048
+    }
6049
+    if( !isset( $input['value']['min'] )) {
6050
+          $input['value']['min'] = 0;
6051
+    }
6052
+    if( !isset( $input['value']['sec'] )) {
6053
+          $input['value']['sec'] = 0;
6054
+    }
6055
+    if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) {
6056
+          $input['value']['tz'] = 'Z';
6057
+    }
5391 6058
     return $input;
5392 6059
   }
5393 6060
 /**
@@ -5403,15 +6070,17 @@  discard block
 block discarded – undo
5403 6070
  * @return void
5404 6071
  */
5405 6072
   function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5406
-    if( !is_array( $valArr )) $valArr = array();
5407
-    if( $index )
5408
-      $index = $index - 1;
5409
-    elseif( 0 < count( $valArr )) {
6073
+    if( !is_array( $valArr )) {
6074
+        $valArr = array();
6075
+    }
6076
+    if( $index ) {
6077
+          $index = $index - 1;
6078
+    } elseif( 0 < count( $valArr )) {
5410 6079
       $index = end( array_keys( $valArr ));
5411 6080
       $index += 1;
6081
+    } else {
6082
+          $index = 0;
5412 6083
     }
5413
-    else
5414
-      $index = 0;
5415 6084
     $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5416 6085
     ksort( $valArr );
5417 6086
   }
@@ -5427,27 +6096,31 @@  discard block
 block discarded – undo
5427 6096
  * @return array
5428 6097
  */
5429 6098
   function _setParams( $params, $defaults=FALSE ) {
5430
-    if( !is_array( $params))
5431
-      $params = array();
6099
+    if( !is_array( $params)) {
6100
+          $params = array();
6101
+    }
5432 6102
     $input = array();
5433 6103
     foreach( $params as $paramKey => $paramValue ) {
5434 6104
       if( is_array( $paramValue )) {
5435 6105
         foreach( $paramValue as $pkey => $pValue ) {
5436
-          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5437
-            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6106
+          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) {
6107
+                      $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6108
+          }
5438 6109
         }
6110
+      } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) {
6111
+              $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
6112
+      }
6113
+      if( 'VALUE' == strtoupper( $paramKey )) {
6114
+              $input['VALUE']                 = strtoupper( $paramValue );
6115
+      } else {
6116
+              $input[strtoupper( $paramKey )] = $paramValue;
5439 6117
       }
5440
-      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5441
-        $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5442
-      if( 'VALUE' == strtoupper( $paramKey ))
5443
-        $input['VALUE']                 = strtoupper( $paramValue );
5444
-      else
5445
-        $input[strtoupper( $paramKey )] = $paramValue;
5446 6118
     }
5447 6119
     if( is_array( $defaults )) {
5448 6120
       foreach( $defaults as $paramKey => $paramValue ) {
5449
-        if( !isset( $input[$paramKey] ))
5450
-          $input[$paramKey] = $paramValue;
6121
+        if( !isset( $input[$paramKey] )) {
6122
+                  $input[$paramKey] = $paramValue;
6123
+        }
5451 6124
       }
5452 6125
     }
5453 6126
     return (0 < count( $input )) ? $input : null;
@@ -5463,13 +6136,15 @@  discard block
 block discarded – undo
5463 6136
  * @return void
5464 6137
  */
5465 6138
   function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5466
-    foreach( $step as $stepix => $stepvalue )
5467
-      $date[$stepix] += $stepvalue;
6139
+    foreach( $step as $stepix => $stepvalue ) {
6140
+          $date[$stepix] += $stepvalue;
6141
+    }
5468 6142
     $timestamp  = $this->_date2timestamp( $date );
5469 6143
     $date       = $this->_timestamp2date( $timestamp, 6 );
5470 6144
     foreach( $date as $k => $v ) {
5471
-      if( ctype_digit( $v ))
5472
-        $date[$k] = (int) $v;
6145
+      if( ctype_digit( $v )) {
6146
+              $date[$k] = (int) $v;
6147
+      }
5473 6148
     }
5474 6149
   }
5475 6150
 /**
@@ -5483,8 +6158,9 @@  discard block
 block discarded – undo
5483 6158
  */
5484 6159
   function _timestamp2date( $timestamp, $parno=6 ) {
5485 6160
     if( is_array( $timestamp )) {
5486
-      if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5487
-        $tz = $timestamp['tz'];
6161
+      if(( 7 == $parno ) && !empty( $timestamp['tz'] )) {
6162
+              $tz = $timestamp['tz'];
6163
+      }
5488 6164
       $timestamp = $timestamp['timestamp'];
5489 6165
     }
5490 6166
     $output = array( 'year'  => date( 'Y', $timestamp )
@@ -5494,8 +6170,9 @@  discard block
 block discarded – undo
5494 6170
              $output['hour'] =  date( 'H', $timestamp );
5495 6171
              $output['min']  =  date( 'i', $timestamp );
5496 6172
              $output['sec']  =  date( 's', $timestamp );
5497
-      if( isset( $tz ))
5498
-        $output['tz'] = $tz;
6173
+      if( isset( $tz )) {
6174
+              $output['tz'] = $tz;
6175
+      }
5499 6176
     }
5500 6177
     return $output;
5501 6178
   }
@@ -5513,8 +6190,9 @@  discard block
 block discarded – undo
5513 6190
     if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5514 6191
        ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5515 6192
        (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5516
-           (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5517
-      return $offset;
6193
+           (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) {
6194
+          return $offset;
6195
+    }
5518 6196
     $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5519 6197
     $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5520 6198
     $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
@@ -5542,7 +6220,9 @@  discard block
 block discarded – undo
5542 6220
         $info = array();
5543 6221
         if( isset( $this->components )) {
5544 6222
           foreach( $this->components as $cix => $component ) {
5545
-            if( empty( $component )) continue;
6223
+            if( empty( $component )) {
6224
+                continue;
6225
+            }
5546 6226
             unset( $component->propix );
5547 6227
             $info[$cix]['ordno'] = $cix + 1;
5548 6228
             $info[$cix]['type']  = $component->objName;
@@ -5568,57 +6248,146 @@  discard block
 block discarded – undo
5568 6248
       case 'PROPINFO':
5569 6249
         $output = array();
5570 6250
         if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5571
-          if( empty( $this->uid['value'] )) $this->_makeuid();
6251
+          if( empty( $this->uid['value'] )) {
6252
+              $this->_makeuid();
6253
+          }
5572 6254
                                               $output['UID']              = 1;
5573 6255
         }
5574
-        if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5575
-        if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
5576
-        if( !empty( $this->description ))     $output['DESCRIPTION']      = count( $this->description );
5577
-        if( !empty( $this->dtstart ))         $output['DTSTART']          = 1;
5578
-        if( !empty( $this->dtend ))           $output['DTEND']            = 1;
5579
-        if( !empty( $this->due ))             $output['DUE']              = 1;
5580
-        if( !empty( $this->duration ))        $output['DURATION']         = 1;
5581
-        if( !empty( $this->rrule ))           $output['RRULE']            = count( $this->rrule );
5582
-        if( !empty( $this->rdate ))           $output['RDATE']            = count( $this->rdate );
5583
-        if( !empty( $this->exdate ))          $output['EXDATE']           = count( $this->exdate );
5584
-        if( !empty( $this->exrule ))          $output['EXRULE']           = count( $this->exrule );
5585
-        if( !empty( $this->action ))          $output['ACTION']           = 1;
5586
-        if( !empty( $this->attach ))          $output['ATTACH']           = count( $this->attach );
5587
-        if( !empty( $this->attendee ))        $output['ATTENDEE']         = count( $this->attendee );
5588
-        if( !empty( $this->categories ))      $output['CATEGORIES']       = count( $this->categories );
5589
-        if( !empty( $this->class ))           $output['CLASS']            = 1;
5590
-        if( !empty( $this->comment ))         $output['COMMENT']          = count( $this->comment );
5591
-        if( !empty( $this->completed ))       $output['COMPLETED']        = 1;
5592
-        if( !empty( $this->contact ))         $output['CONTACT']          = count( $this->contact );
5593
-        if( !empty( $this->created ))         $output['CREATED']          = 1;
5594
-        if( !empty( $this->freebusy ))        $output['FREEBUSY']         = count( $this->freebusy );
5595
-        if( !empty( $this->geo ))             $output['GEO']              = 1;
5596
-        if( !empty( $this->lastmodified ))    $output['LAST-MODIFIED']    = 1;
5597
-        if( !empty( $this->location ))        $output['LOCATION']         = 1;
5598
-        if( !empty( $this->organizer ))       $output['ORGANIZER']        = 1;
5599
-        if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1;
5600
-        if( !empty( $this->priority ))        $output['PRIORITY']         = 1;
5601
-        if( !empty( $this->recurrenceid ))    $output['RECURRENCE-ID']    = 1;
5602
-        if( !empty( $this->relatedto ))       $output['RELATED-TO']       = count( $this->relatedto );
5603
-        if( !empty( $this->repeat ))          $output['REPEAT']           = 1;
5604
-        if( !empty( $this->requeststatus ))   $output['REQUEST-STATUS']   = count( $this->requeststatus );
5605
-        if( !empty( $this->resources ))       $output['RESOURCES']        = count( $this->resources );
5606
-        if( !empty( $this->sequence ))        $output['SEQUENCE']         = 1;
5607
-        if( !empty( $this->status ))          $output['STATUS']           = 1;
5608
-        if( !empty( $this->transp ))          $output['TRANSP']           = 1;
5609
-        if( !empty( $this->trigger ))         $output['TRIGGER']          = 1;
5610
-        if( !empty( $this->tzid ))            $output['TZID']             = 1;
5611
-        if( !empty( $this->tzname ))          $output['TZNAME']           = count( $this->tzname );
5612
-        if( !empty( $this->tzoffsetfrom ))    $output['TZOFFSETTFROM']    = 1;
5613
-        if( !empty( $this->tzoffsetto ))      $output['TZOFFSETTO']       = 1;
5614
-        if( !empty( $this->tzurl ))           $output['TZURL']            = 1;
5615
-        if( !empty( $this->url ))             $output['URL']              = 1;
5616
-        if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
6256
+        if( !empty( $this->dtstamp )) {
6257
+            $output['DTSTAMP']          = 1;
6258
+        }
6259
+        if( !empty( $this->summary )) {
6260
+            $output['SUMMARY']          = 1;
6261
+        }
6262
+        if( !empty( $this->description )) {
6263
+            $output['DESCRIPTION']      = count( $this->description );
6264
+        }
6265
+        if( !empty( $this->dtstart )) {
6266
+            $output['DTSTART']          = 1;
6267
+        }
6268
+        if( !empty( $this->dtend )) {
6269
+            $output['DTEND']            = 1;
6270
+        }
6271
+        if( !empty( $this->due )) {
6272
+            $output['DUE']              = 1;
6273
+        }
6274
+        if( !empty( $this->duration )) {
6275
+            $output['DURATION']         = 1;
6276
+        }
6277
+        if( !empty( $this->rrule )) {
6278
+            $output['RRULE']            = count( $this->rrule );
6279
+        }
6280
+        if( !empty( $this->rdate )) {
6281
+            $output['RDATE']            = count( $this->rdate );
6282
+        }
6283
+        if( !empty( $this->exdate )) {
6284
+            $output['EXDATE']           = count( $this->exdate );
6285
+        }
6286
+        if( !empty( $this->exrule )) {
6287
+            $output['EXRULE']           = count( $this->exrule );
6288
+        }
6289
+        if( !empty( $this->action )) {
6290
+            $output['ACTION']           = 1;
6291
+        }
6292
+        if( !empty( $this->attach )) {
6293
+            $output['ATTACH']           = count( $this->attach );
6294
+        }
6295
+        if( !empty( $this->attendee )) {
6296
+            $output['ATTENDEE']         = count( $this->attendee );
6297
+        }
6298
+        if( !empty( $this->categories )) {
6299
+            $output['CATEGORIES']       = count( $this->categories );
6300
+        }
6301
+        if( !empty( $this->class )) {
6302
+            $output['CLASS']            = 1;
6303
+        }
6304
+        if( !empty( $this->comment )) {
6305
+            $output['COMMENT']          = count( $this->comment );
6306
+        }
6307
+        if( !empty( $this->completed )) {
6308
+            $output['COMPLETED']        = 1;
6309
+        }
6310
+        if( !empty( $this->contact )) {
6311
+            $output['CONTACT']          = count( $this->contact );
6312
+        }
6313
+        if( !empty( $this->created )) {
6314
+            $output['CREATED']          = 1;
6315
+        }
6316
+        if( !empty( $this->freebusy )) {
6317
+            $output['FREEBUSY']         = count( $this->freebusy );
6318
+        }
6319
+        if( !empty( $this->geo )) {
6320
+            $output['GEO']              = 1;
6321
+        }
6322
+        if( !empty( $this->lastmodified )) {
6323
+            $output['LAST-MODIFIED']    = 1;
6324
+        }
6325
+        if( !empty( $this->location )) {
6326
+            $output['LOCATION']         = 1;
6327
+        }
6328
+        if( !empty( $this->organizer )) {
6329
+            $output['ORGANIZER']        = 1;
6330
+        }
6331
+        if( !empty( $this->percentcomplete )) {
6332
+            $output['PERCENT-COMPLETE'] = 1;
6333
+        }
6334
+        if( !empty( $this->priority )) {
6335
+            $output['PRIORITY']         = 1;
6336
+        }
6337
+        if( !empty( $this->recurrenceid )) {
6338
+            $output['RECURRENCE-ID']    = 1;
6339
+        }
6340
+        if( !empty( $this->relatedto )) {
6341
+            $output['RELATED-TO']       = count( $this->relatedto );
6342
+        }
6343
+        if( !empty( $this->repeat )) {
6344
+            $output['REPEAT']           = 1;
6345
+        }
6346
+        if( !empty( $this->requeststatus )) {
6347
+            $output['REQUEST-STATUS']   = count( $this->requeststatus );
6348
+        }
6349
+        if( !empty( $this->resources )) {
6350
+            $output['RESOURCES']        = count( $this->resources );
6351
+        }
6352
+        if( !empty( $this->sequence )) {
6353
+            $output['SEQUENCE']         = 1;
6354
+        }
6355
+        if( !empty( $this->status )) {
6356
+            $output['STATUS']           = 1;
6357
+        }
6358
+        if( !empty( $this->transp )) {
6359
+            $output['TRANSP']           = 1;
6360
+        }
6361
+        if( !empty( $this->trigger )) {
6362
+            $output['TRIGGER']          = 1;
6363
+        }
6364
+        if( !empty( $this->tzid )) {
6365
+            $output['TZID']             = 1;
6366
+        }
6367
+        if( !empty( $this->tzname )) {
6368
+            $output['TZNAME']           = count( $this->tzname );
6369
+        }
6370
+        if( !empty( $this->tzoffsetfrom )) {
6371
+            $output['TZOFFSETTFROM']    = 1;
6372
+        }
6373
+        if( !empty( $this->tzoffsetto )) {
6374
+            $output['TZOFFSETTO']       = 1;
6375
+        }
6376
+        if( !empty( $this->tzurl )) {
6377
+            $output['TZURL']            = 1;
6378
+        }
6379
+        if( !empty( $this->url )) {
6380
+            $output['URL']              = 1;
6381
+        }
6382
+        if( !empty( $this->xprop )) {
6383
+            $output['X-PROP']           = count( $this->xprop );
6384
+        }
5617 6385
         return $output;
5618 6386
         break;
5619 6387
       case 'UNIQUE_ID':
5620
-        if( empty( $this->unique_id ))
5621
-          $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6388
+        if( empty( $this->unique_id )) {
6389
+                  $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6390
+        }
5622 6391
         return $this->unique_id;
5623 6392
         break;
5624 6393
     }
@@ -5667,13 +6436,16 @@  discard block
 block discarded – undo
5667 6436
         $res    = TRUE;
5668 6437
         break;
5669 6438
     }
5670
-    if( !$res ) return FALSE;
6439
+    if( !$res ) {
6440
+        return FALSE;
6441
+    }
5671 6442
     if( isset( $subcfg ) && !empty( $this->components )) {
5672 6443
       foreach( $subcfg as $cfgkey => $cfgvalue ) {
5673 6444
         foreach( $this->components as $cix => $component ) {
5674 6445
           $res = $component->setConfig( $cfgkey, $cfgvalue );
5675
-          if( !$res )
5676
-            break 2;
6446
+          if( !$res ) {
6447
+                      break 2;
6448
+          }
5677 6449
           $this->components[$cix] = $component; // PHP4 compliant
5678 6450
         }
5679 6451
       }
@@ -5691,12 +6463,15 @@  discard block
 block discarded – undo
5691 6463
  * @return bool, if successfull delete TRUE
5692 6464
  */
5693 6465
   function deleteProperty( $propName, $propix=FALSE ) {
5694
-    if( $this->_notExistProp( $propName )) return FALSE;
6466
+    if( $this->_notExistProp( $propName )) {
6467
+        return FALSE;
6468
+    }
5695 6469
     $propName = strtoupper( $propName );
5696 6470
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5697 6471
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5698
-      if( !$propix )
5699
-        $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6472
+      if( !$propix ) {
6473
+              $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6474
+      }
5700 6475
       $this->propdelix[$propName] = --$propix;
5701 6476
     }
5702 6477
     $return = FALSE;
@@ -5750,8 +6525,9 @@  discard block
 block discarded – undo
5750 6525
         }
5751 6526
         break;
5752 6527
       case 'DTSTAMP':
5753
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5754
-          return FALSE;
6528
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6529
+                  return FALSE;
6530
+        }
5755 6531
         if( !empty( $this->dtstamp )) {
5756 6532
           $this->dtstamp = '';
5757 6533
           $return = TRUE;
@@ -5905,8 +6681,9 @@  discard block
 block discarded – undo
5905 6681
         }
5906 6682
         break;
5907 6683
       case 'UID':
5908
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5909
-          return FALSE;
6684
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6685
+                  return FALSE;
6686
+        }
5910 6687
         if( !empty( $this->uid )) {
5911 6688
           $this->uid = '';
5912 6689
           $return = TRUE;
@@ -5921,18 +6698,23 @@  discard block
 block discarded – undo
5921 6698
       default:
5922 6699
         $reduced = '';
5923 6700
         if( $propName != 'X-PROP' ) {
5924
-          if( !isset( $this->xprop[$propName] )) return FALSE;
6701
+          if( !isset( $this->xprop[$propName] )) {
6702
+              return FALSE;
6703
+          }
5925 6704
           foreach( $this->xprop as $k => $a ) {
5926
-            if(( $k != $propName ) && !empty( $a ))
5927
-              $reduced[$k] = $a;
6705
+            if(( $k != $propName ) && !empty( $a )) {
6706
+                          $reduced[$k] = $a;
6707
+            }
6708
+          }
6709
+        } else {
6710
+          if( count( $this->xprop ) <= $propix ) {
6711
+              return FALSE;
5928 6712
           }
5929
-        }
5930
-        else {
5931
-          if( count( $this->xprop ) <= $propix )  return FALSE;
5932 6713
           $xpropno = 0;
5933 6714
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5934
-            if( $propix != $xpropno )
5935
-              $reduced[$xpropkey] = $xpropvalue;
6715
+            if( $propix != $xpropno ) {
6716
+                          $reduced[$xpropkey] = $xpropvalue;
6717
+            }
5936 6718
             $xpropno++;
5937 6719
           }
5938 6720
         }
@@ -5952,9 +6734,13 @@  discard block
 block discarded – undo
5952 6734
  * @return bool TRUE
5953 6735
  */
5954 6736
   function deletePropertyM( & $multiprop, $propix=0 ) {
5955
-    if( !isset( $multiprop[$propix])) return FALSE;
6737
+    if( !isset( $multiprop[$propix])) {
6738
+        return FALSE;
6739
+    }
5956 6740
     unset( $multiprop[$propix] );
5957
-    if( empty( $multiprop )) $multiprop = '';
6741
+    if( empty( $multiprop )) {
6742
+        $multiprop = '';
6743
+    }
5958 6744
     return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5959 6745
   }
5960 6746
 /**
@@ -5971,184 +6757,277 @@  discard block
 block discarded – undo
5971 6757
  * @return mixed
5972 6758
  */
5973 6759
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5974
-    if( $this->_notExistProp( $propName )) return FALSE;
6760
+    if( $this->_notExistProp( $propName )) {
6761
+        return FALSE;
6762
+    }
5975 6763
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
5976 6764
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5977 6765
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5978
-      if( !$propix )
5979
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6766
+      if( !$propix ) {
6767
+              $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6768
+      }
5980 6769
       $this->propix[$propName] = --$propix;
5981 6770
     }
5982 6771
     switch( $propName ) {
5983 6772
       case 'ACTION':
5984
-        if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
6773
+        if( !empty( $this->action['value'] )) {
6774
+            return ( $inclParam ) ? $this->action : $this->action['value'];
6775
+        }
5985 6776
         break;
5986 6777
       case 'ATTACH':
5987
-        if( !isset( $this->attach[$propix] )) return FALSE;
6778
+        if( !isset( $this->attach[$propix] )) {
6779
+            return FALSE;
6780
+        }
5988 6781
         return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5989 6782
         break;
5990 6783
       case 'ATTENDEE':
5991
-        if( !isset( $this->attendee[$propix] )) return FALSE;
6784
+        if( !isset( $this->attendee[$propix] )) {
6785
+            return FALSE;
6786
+        }
5992 6787
         return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5993 6788
         break;
5994 6789
       case 'CATEGORIES':
5995
-        if( !isset( $this->categories[$propix] )) return FALSE;
6790
+        if( !isset( $this->categories[$propix] )) {
6791
+            return FALSE;
6792
+        }
5996 6793
         return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5997 6794
         break;
5998 6795
       case 'CLASS':
5999
-        if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
6796
+        if( !empty( $this->class['value'] )) {
6797
+            return ( $inclParam ) ? $this->class : $this->class['value'];
6798
+        }
6000 6799
         break;
6001 6800
       case 'COMMENT':
6002
-        if( !isset( $this->comment[$propix] )) return FALSE;
6801
+        if( !isset( $this->comment[$propix] )) {
6802
+            return FALSE;
6803
+        }
6003 6804
         return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6004 6805
         break;
6005 6806
       case 'COMPLETED':
6006
-        if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6807
+        if( !empty( $this->completed['value'] )) {
6808
+            return ( $inclParam ) ? $this->completed : $this->completed['value'];
6809
+        }
6007 6810
         break;
6008 6811
       case 'CONTACT':
6009
-        if( !isset( $this->contact[$propix] )) return FALSE;
6812
+        if( !isset( $this->contact[$propix] )) {
6813
+            return FALSE;
6814
+        }
6010 6815
         return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6011 6816
         break;
6012 6817
       case 'CREATED':
6013
-        if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6818
+        if( !empty( $this->created['value'] )) {
6819
+            return ( $inclParam ) ? $this->created : $this->created['value'];
6820
+        }
6014 6821
         break;
6015 6822
       case 'DESCRIPTION':
6016
-        if( !isset( $this->description[$propix] )) return FALSE;
6823
+        if( !isset( $this->description[$propix] )) {
6824
+            return FALSE;
6825
+        }
6017 6826
         return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6018 6827
         break;
6019 6828
       case 'DTEND':
6020
-        if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6829
+        if( !empty( $this->dtend['value'] )) {
6830
+            return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6831
+        }
6021 6832
         break;
6022 6833
       case 'DTSTAMP':
6023
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6024
-          return;
6025
-        if( !isset( $this->dtstamp['value'] ))
6026
-          $this->_makeDtstamp();
6834
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6835
+                  return;
6836
+        }
6837
+        if( !isset( $this->dtstamp['value'] )) {
6838
+                  $this->_makeDtstamp();
6839
+        }
6027 6840
         return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6028 6841
         break;
6029 6842
       case 'DTSTART':
6030
-        if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6843
+        if( !empty( $this->dtstart['value'] )) {
6844
+            return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6845
+        }
6031 6846
         break;
6032 6847
       case 'DUE':
6033
-        if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6848
+        if( !empty( $this->due['value'] )) {
6849
+            return ( $inclParam ) ? $this->due : $this->due['value'];
6850
+        }
6034 6851
         break;
6035 6852
       case 'DURATION':
6036
-        if( !isset( $this->duration['value'] )) return FALSE;
6853
+        if( !isset( $this->duration['value'] )) {
6854
+            return FALSE;
6855
+        }
6037 6856
         $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6038 6857
         return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6039 6858
         break;
6040 6859
       case 'EXDATE':
6041
-        if( !isset( $this->exdate[$propix] )) return FALSE;
6860
+        if( !isset( $this->exdate[$propix] )) {
6861
+            return FALSE;
6862
+        }
6042 6863
         return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6043 6864
         break;
6044 6865
       case 'EXRULE':
6045
-        if( !isset( $this->exrule[$propix] )) return FALSE;
6866
+        if( !isset( $this->exrule[$propix] )) {
6867
+            return FALSE;
6868
+        }
6046 6869
         return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6047 6870
         break;
6048 6871
       case 'FREEBUSY':
6049
-        if( !isset( $this->freebusy[$propix] )) return FALSE;
6872
+        if( !isset( $this->freebusy[$propix] )) {
6873
+            return FALSE;
6874
+        }
6050 6875
         return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6051 6876
         break;
6052 6877
       case 'GEO':
6053
-        if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6878
+        if( !empty( $this->geo['value'] )) {
6879
+            return ( $inclParam ) ? $this->geo : $this->geo['value'];
6880
+        }
6054 6881
         break;
6055 6882
       case 'LAST-MODIFIED':
6056
-        if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6883
+        if( !empty( $this->lastmodified['value'] )) {
6884
+            return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6885
+        }
6057 6886
         break;
6058 6887
       case 'LOCATION':
6059
-        if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6888
+        if( !empty( $this->location['value'] )) {
6889
+            return ( $inclParam ) ? $this->location : $this->location['value'];
6890
+        }
6060 6891
         break;
6061 6892
       case 'ORGANIZER':
6062
-        if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6893
+        if( !empty( $this->organizer['value'] )) {
6894
+            return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6895
+        }
6063 6896
         break;
6064 6897
       case 'PERCENT-COMPLETE':
6065
-        if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6898
+        if( !empty( $this->percentcomplete['value'] )) {
6899
+            return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6900
+        }
6066 6901
         break;
6067 6902
       case 'PRIORITY':
6068
-        if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6903
+        if( !empty( $this->priority['value'] )) {
6904
+            return ( $inclParam ) ? $this->priority : $this->priority['value'];
6905
+        }
6069 6906
         break;
6070 6907
       case 'RDATE':
6071
-        if( !isset( $this->rdate[$propix] )) return FALSE;
6908
+        if( !isset( $this->rdate[$propix] )) {
6909
+            return FALSE;
6910
+        }
6072 6911
         return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6073 6912
         break;
6074 6913
       case 'RECURRENCE-ID':
6075
-        if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6914
+        if( !empty( $this->recurrenceid['value'] )) {
6915
+            return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6916
+        }
6076 6917
         break;
6077 6918
       case 'RELATED-TO':
6078
-        if( !isset( $this->relatedto[$propix] )) return FALSE;
6919
+        if( !isset( $this->relatedto[$propix] )) {
6920
+            return FALSE;
6921
+        }
6079 6922
         return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6080 6923
         break;
6081 6924
       case 'REPEAT':
6082
-        if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6925
+        if( !empty( $this->repeat['value'] )) {
6926
+            return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6927
+        }
6083 6928
         break;
6084 6929
       case 'REQUEST-STATUS':
6085
-        if( !isset( $this->requeststatus[$propix] )) return FALSE;
6930
+        if( !isset( $this->requeststatus[$propix] )) {
6931
+            return FALSE;
6932
+        }
6086 6933
         return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6087 6934
         break;
6088 6935
       case 'RESOURCES':
6089
-        if( !isset( $this->resources[$propix] )) return FALSE;
6936
+        if( !isset( $this->resources[$propix] )) {
6937
+            return FALSE;
6938
+        }
6090 6939
         return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6091 6940
         break;
6092 6941
       case 'RRULE':
6093
-        if( !isset( $this->rrule[$propix] )) return FALSE;
6942
+        if( !isset( $this->rrule[$propix] )) {
6943
+            return FALSE;
6944
+        }
6094 6945
         return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6095 6946
         break;
6096 6947
       case 'SEQUENCE':
6097
-        if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6948
+        if( !empty( $this->sequence['value'] )) {
6949
+            return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6950
+        }
6098 6951
         break;
6099 6952
       case 'STATUS':
6100
-        if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6953
+        if( !empty( $this->status['value'] )) {
6954
+            return ( $inclParam ) ? $this->status : $this->status['value'];
6955
+        }
6101 6956
         break;
6102 6957
       case 'SUMMARY':
6103
-        if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6958
+        if( !empty( $this->summary['value'] )) {
6959
+            return ( $inclParam ) ? $this->summary : $this->summary['value'];
6960
+        }
6104 6961
         break;
6105 6962
       case 'TRANSP':
6106
-        if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6963
+        if( !empty( $this->transp['value'] )) {
6964
+            return ( $inclParam ) ? $this->transp : $this->transp['value'];
6965
+        }
6107 6966
         break;
6108 6967
       case 'TRIGGER':
6109
-        if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6968
+        if( !empty( $this->trigger['value'] )) {
6969
+            return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6970
+        }
6110 6971
         break;
6111 6972
       case 'TZID':
6112
-        if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6973
+        if( !empty( $this->tzid['value'] )) {
6974
+            return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6975
+        }
6113 6976
         break;
6114 6977
       case 'TZNAME':
6115
-        if( !isset( $this->tzname[$propix] )) return FALSE;
6978
+        if( !isset( $this->tzname[$propix] )) {
6979
+            return FALSE;
6980
+        }
6116 6981
         return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6117 6982
         break;
6118 6983
       case 'TZOFFSETFROM':
6119
-        if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6984
+        if( !empty( $this->tzoffsetfrom['value'] )) {
6985
+            return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6986
+        }
6120 6987
         break;
6121 6988
       case 'TZOFFSETTO':
6122
-        if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6989
+        if( !empty( $this->tzoffsetto['value'] )) {
6990
+            return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6991
+        }
6123 6992
         break;
6124 6993
       case 'TZURL':
6125
-        if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6994
+        if( !empty( $this->tzurl['value'] )) {
6995
+            return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6996
+        }
6126 6997
         break;
6127 6998
       case 'UID':
6128
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6129
-          return FALSE;
6130
-        if( empty( $this->uid['value'] ))
6131
-          $this->_makeuid();
6999
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
7000
+                  return FALSE;
7001
+        }
7002
+        if( empty( $this->uid['value'] )) {
7003
+                  $this->_makeuid();
7004
+        }
6132 7005
         return ( $inclParam ) ? $this->uid : $this->uid['value'];
6133 7006
         break;
6134 7007
       case 'URL':
6135
-        if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
7008
+        if( !empty( $this->url['value'] )) {
7009
+            return ( $inclParam ) ? $this->url : $this->url['value'];
7010
+        }
6136 7011
         break;
6137 7012
       default:
6138 7013
         if( $propName != 'X-PROP' ) {
6139
-          if( !isset( $this->xprop[$propName] )) return FALSE;
7014
+          if( !isset( $this->xprop[$propName] )) {
7015
+              return FALSE;
7016
+          }
6140 7017
           return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6141 7018
                                 : array( $propName, $this->xprop[$propName]['value'] );
6142
-        }
6143
-        else {
6144
-          if( empty( $this->xprop )) return FALSE;
7019
+        } else {
7020
+          if( empty( $this->xprop )) {
7021
+              return FALSE;
7022
+          }
6145 7023
           $xpropno = 0;
6146 7024
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6147
-            if( $propix == $xpropno )
6148
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
7025
+            if( $propix == $xpropno ) {
7026
+                          return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6149 7027
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6150
-            else
6151
-              $xpropno++;
7028
+            } else {
7029
+                          $xpropno++;
7030
+            }
6152 7031
           }
6153 7032
           return FALSE; // not found ??
6154 7033
         }
@@ -6167,15 +7046,21 @@  discard block
 block discarded – undo
6167 7046
  */
6168 7047
   function setProperty() {
6169 7048
     $numargs    = func_num_args();
6170
-    if( 1 > $numargs ) return FALSE;
7049
+    if( 1 > $numargs ) {
7050
+        return FALSE;
7051
+    }
6171 7052
     $arglist    = func_get_args();
6172
-    if( $this->_notExistProp( $arglist[0] )) return FALSE;
6173
-    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
6174
-      return FALSE;
7053
+    if( $this->_notExistProp( $arglist[0] )) {
7054
+        return FALSE;
7055
+    }
7056
+    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) {
7057
+          return FALSE;
7058
+    }
6175 7059
     $arglist[0] = strtoupper( $arglist[0] );
6176 7060
     for( $argix=$numargs; $argix < 12; $argix++ ) {
6177
-      if( !isset( $arglist[$argix] ))
6178
-        $arglist[$argix] = null;
7061
+      if( !isset( $arglist[$argix] )) {
7062
+              $arglist[$argix] = null;
7063
+      }
6179 7064
     }
6180 7065
     switch( $arglist[0] ) {
6181 7066
       case 'ACTION':
@@ -6289,20 +7174,19 @@  discard block
 block discarded – undo
6289 7174
             $this->setComponent( $comp );
6290 7175
             $comp =  & $this;
6291 7176
             continue;
6292
-          }
6293
-          elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
7177
+          } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6294 7178
             $comp = new valarm();
6295 7179
             continue;
7180
+          } else {
7181
+                      $comp->unparsed[] = $line;
6296 7182
           }
6297
-          else
6298
-            $comp->unparsed[] = $line;
6299 7183
         }
7184
+      } else {
7185
+              $this->unparsed = array( trim( $unparsedtext ));
6300 7186
       }
6301
-      else
6302
-        $this->unparsed = array( trim( $unparsedtext ));
7187
+    } elseif( !isset( $this->unparsed )) {
7188
+          $this->unparsed = array();
6303 7189
     }
6304
-    elseif( !isset( $this->unparsed ))
6305
-      $this->unparsed = array();
6306 7190
             /* concatenate property values spread over several lines */
6307 7191
     $lastix    = -1;
6308 7192
     $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
@@ -6326,8 +7210,7 @@  discard block
 block discarded – undo
6326 7210
         $newProp = FALSE;
6327 7211
         $lastix++;
6328 7212
         $proprows[$lastix]  = $line;
6329
-      }
6330
-      else {
7213
+      } else {
6331 7214
             /* remove line breaks */
6332 7215
         if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6333 7216
            (  ' ' == substr( $line, 0, 1 ))) {
@@ -6340,14 +7223,15 @@  discard block
 block discarded – undo
6340 7223
             /* parse each property 'line' */
6341 7224
     foreach( $proprows as $line ) {
6342 7225
       $line = str_replace( "\n ", '', $line );
6343
-      if( '\n' == substr( $line, -2 ))
6344
-        $line = substr( $line, 0, strlen( $line ) - 2 );
7226
+      if( '\n' == substr( $line, -2 )) {
7227
+              $line = substr( $line, 0, strlen( $line ) - 2 );
7228
+      }
6345 7229
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6346 7230
       $cix = $propname = null;
6347 7231
       for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6348
-        if( in_array( $line{$cix}, array( ':', ';' )))
6349
-          break;
6350
-        else {
7232
+        if( in_array( $line{$cix}, array( ':', ';' ))) {
7233
+                  break;
7234
+        } else {
6351 7235
           $propname .= $line{$cix};
6352 7236
         }
6353 7237
       }
@@ -6380,27 +7264,30 @@  discard block
 block discarded – undo
6380 7264
             break;
6381 7265
           }
6382 7266
         }
6383
-        if( ';' == $line{$cix} )
6384
-          $attr[++$attrix] = null;
6385
-        else
6386
-          $attr[$attrix] .= $line{$cix};
7267
+        if( ';' == $line{$cix} ) {
7268
+                  $attr[++$attrix] = null;
7269
+        } else {
7270
+                  $attr[$attrix] .= $line{$cix};
7271
+        }
6387 7272
       }
6388 7273
             /* make attributes in array format */
6389 7274
       $propattr = array();
6390 7275
       foreach( $attr as $attribute ) {
6391 7276
         $attrsplit = explode( '=', $attribute, 2 );
6392
-        if( 1 < count( $attrsplit ))
6393
-          $propattr[$attrsplit[0]] = $attrsplit[1];
6394
-        else
6395
-          $propattr[] = $attribute;
7277
+        if( 1 < count( $attrsplit )) {
7278
+                  $propattr[$attrsplit[0]] = $attrsplit[1];
7279
+        } else {
7280
+                  $propattr[] = $attribute;
7281
+        }
6396 7282
       }
6397 7283
             /* call setProperty( $propname.. . */
6398 7284
       switch( $propname ) {
6399 7285
         case 'ATTENDEE':
6400 7286
           foreach( $propattr as $pix => $attr ) {
6401 7287
             $attr2 = explode( ',', $attr );
6402
-              if( 1 < count( $attr2 ))
6403
-                $propattr[$pix] = $attr2;
7288
+              if( 1 < count( $attr2 )) {
7289
+                              $propattr[$pix] = $attr2;
7290
+              }
6404 7291
           }
6405 7292
           $this->setProperty( $propname, $line, $propattr );
6406 7293
           break;
@@ -6418,13 +7305,14 @@  discard block
 block discarded – undo
6418 7305
             }
6419 7306
             if( 1 < count( $content )) {
6420 7307
               $content = array_values( $content );
6421
-              foreach( $content as $cix => $contentPart )
6422
-                $content[$cix] = $this->_strunrep( $contentPart );
7308
+              foreach( $content as $cix => $contentPart ) {
7309
+                              $content[$cix] = $this->_strunrep( $contentPart );
7310
+              }
6423 7311
               $this->setProperty( $propname, $content, $propattr );
6424 7312
               break;
7313
+            } else {
7314
+                          $line = reset( $content );
6425 7315
             }
6426
-            else
6427
-              $line = reset( $content );
6428 7316
           }
6429 7317
         case 'X-':
6430 7318
           $propname = ( isset( $propname2 )) ? $propname2 : $propname;
@@ -6433,8 +7321,9 @@  discard block
 block discarded – undo
6433 7321
         case 'DESCRIPTION':
6434 7322
         case 'LOCATION':
6435 7323
         case 'SUMMARY':
6436
-          if( empty( $line ))
6437
-            $propattr = null;
7324
+          if( empty( $line )) {
7325
+                      $propattr = null;
7326
+          }
6438 7327
           $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6439 7328
           unset( $propname2 );
6440 7329
           break;
@@ -6454,15 +7343,17 @@  discard block
 block discarded – undo
6454 7343
           $values = explode( ',', $line );
6455 7344
           foreach( $values as $vix => $value ) {
6456 7345
             $value2 = explode( '/', $value );
6457
-            if( 1 < count( $value2 ))
6458
-              $values[$vix] = $value2;
7346
+            if( 1 < count( $value2 )) {
7347
+                          $values[$vix] = $value2;
7348
+            }
6459 7349
           }
6460 7350
           $this->setProperty( $propname, $fbtype, $values, $propattr );
6461 7351
           break;
6462 7352
         case 'GEO':
6463 7353
           $value = explode( ';', $line, 2 );
6464
-          if( 2 > count( $value ))
6465
-            $value[1] = null;
7354
+          if( 2 > count( $value )) {
7355
+                      $value[1] = null;
7356
+          }
6466 7357
           $this->setProperty( $propname, $value[0], $value[1], $propattr );
6467 7358
           break;
6468 7359
         case 'EXDATE':
@@ -6477,8 +7368,9 @@  discard block
 block discarded – undo
6477 7368
           $values = explode( ',', $line );
6478 7369
           foreach( $values as $vix => $value ) {
6479 7370
             $value2 = explode( '/', $value );
6480
-            if( 1 < count( $value2 ))
6481
-              $values[$vix] = $value2;
7371
+            if( 1 < count( $value2 )) {
7372
+                          $values[$vix] = $value2;
7373
+            }
6482 7374
           }
6483 7375
           $this->setProperty( $propname, $values, $propattr );
6484 7376
           break;
@@ -6487,8 +7379,10 @@  discard block
 block discarded – undo
6487 7379
           $values = explode( ';', $line );
6488 7380
           $recur = array();
6489 7381
           foreach( $values as $value2 ) {
6490
-            if( empty( $value2 ))
6491
-              continue; // ;-char in ending position ???
7382
+            if( empty( $value2 )) {
7383
+                          continue;
7384
+            }
7385
+            // ;-char in ending position ???
6492 7386
             $value3 = explode( '=', $value2, 2 );
6493 7387
             $rulelabel = strtoupper( $value3[0] );
6494 7388
             switch( $rulelabel ) {
@@ -6502,38 +7396,44 @@  discard block
 block discarded – undo
6502 7396
                     if(( ctype_alpha( substr( $value5, -1 ))) &&
6503 7397
                        ( ctype_alpha( substr( $value5, -2, 1 )))) {
6504 7398
                       $dayname = substr( $value5, -2, 2 );
6505
-                      if( 2 < strlen( $value5 ))
6506
-                        $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7399
+                      if( 2 < strlen( $value5 )) {
7400
+                                              $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7401
+                      }
7402
+                    }
7403
+                    if( $dayno ) {
7404
+                                          $value6[] = $dayno;
7405
+                    }
7406
+                    if( $dayname ) {
7407
+                                          $value6['DAY'] = $dayname;
6507 7408
                     }
6508
-                    if( $dayno )
6509
-                      $value6[] = $dayno;
6510
-                    if( $dayname )
6511
-                      $value6['DAY'] = $dayname;
6512 7409
                     $value4[$v5ix] = $value6;
6513 7410
                   }
6514
-                }
6515
-                else {
7411
+                } else {
6516 7412
                   $value4 = array();
6517 7413
                   $dayno  = $dayname = null;
6518 7414
                   $value5 = trim( (string) $value3[1] );
6519 7415
                   if(( ctype_alpha( substr( $value5, -1 ))) &&
6520 7416
                      ( ctype_alpha( substr( $value5, -2, 1 )))) {
6521 7417
                       $dayname = substr( $value5, -2, 2 );
6522
-                    if( 2 < strlen( $value5 ))
6523
-                      $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7418
+                    if( 2 < strlen( $value5 )) {
7419
+                                          $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7420
+                    }
7421
+                  }
7422
+                  if( $dayno ) {
7423
+                                      $value4[] = $dayno;
7424
+                  }
7425
+                  if( $dayname ) {
7426
+                                      $value4['DAY'] = $dayname;
6524 7427
                   }
6525
-                  if( $dayno )
6526
-                    $value4[] = $dayno;
6527
-                  if( $dayname )
6528
-                    $value4['DAY'] = $dayname;
6529 7428
                 }
6530 7429
                 $recur[$rulelabel] = $value4;
6531 7430
                 break;
6532 7431
               }
6533 7432
               default: {
6534 7433
                 $value4 = explode( ',', $value3[1] );
6535
-                if( 1 < count( $value4 ))
6536
-                  $value3[1] = $value4;
7434
+                if( 1 < count( $value4 )) {
7435
+                                  $value3[1] = $value4;
7436
+                }
6537 7437
                 $recur[$rulelabel] = $value3[1];
6538 7438
                 break;
6539 7439
               }
@@ -6549,8 +7449,9 @@  discard block
 block discarded – undo
6549 7449
     unset( $this->unparsed, $proprows );
6550 7450
     if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6551 7451
       for( $six = 0; $six < count( $this->components ); $six++ ) {
6552
-        if( !empty( $this->components[$six]->unparsed ))
6553
-          $this->components[$six]->parse();
7452
+        if( !empty( $this->components[$six]->unparsed )) {
7453
+                  $this->components[$six]->parse();
7454
+        }
6554 7455
       }
6555 7456
     }
6556 7457
   }
@@ -6581,32 +7482,33 @@  discard block
 block discarded – undo
6581 7482
  * @return void
6582 7483
  */
6583 7484
   function deleteComponent( $arg1, $arg2=FALSE  ) {
6584
-    if( !isset( $this->components )) return FALSE;
7485
+    if( !isset( $this->components )) {
7486
+        return FALSE;
7487
+    }
6585 7488
     $argType = $index = null;
6586 7489
     if ( ctype_digit( (string) $arg1 )) {
6587 7490
       $argType = 'INDEX';
6588 7491
       $index   = (int) $arg1 - 1;
6589
-    }
6590
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7492
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6591 7493
       $argType = strtolower( $arg1 );
6592 7494
       $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6593 7495
     }
6594 7496
     $cix2dC = 0;
6595 7497
     foreach ( $this->components as $cix => $component) {
6596
-      if( empty( $component )) continue;
7498
+      if( empty( $component )) {
7499
+          continue;
7500
+      }
6597 7501
       unset( $component->propix );
6598 7502
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6599 7503
         unset( $this->components[$cix] );
6600 7504
         return TRUE;
6601
-      }
6602
-      elseif( $argType == $component->objName ) {
7505
+      } elseif( $argType == $component->objName ) {
6603 7506
         if( $index == $cix2dC ) {
6604 7507
           unset( $this->components[$cix] );
6605 7508
           return TRUE;
6606 7509
         }
6607 7510
         $cix2dC++;
6608
-      }
6609
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
7511
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6610 7512
         unset( $this->components[$cix] );
6611 7513
         return TRUE;
6612 7514
       }
@@ -6623,43 +7525,47 @@  discard block
 block discarded – undo
6623 7525
  * @return object
6624 7526
  */
6625 7527
   function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6626
-    if( !isset( $this->components )) return FALSE;
7528
+    if( !isset( $this->components )) {
7529
+        return FALSE;
7530
+    }
6627 7531
     $index = $argType = null;
6628 7532
     if ( !$arg1 ) {
6629 7533
       $argType = 'INDEX';
6630 7534
       $index   = $this->compix['INDEX'] =
6631 7535
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6632
-    }
6633
-    elseif ( ctype_digit( (string) $arg1 )) {
7536
+    } elseif ( ctype_digit( (string) $arg1 )) {
6634 7537
       $argType = 'INDEX';
6635 7538
       $index   = (int) $arg1;
6636 7539
       unset( $this->compix );
6637
-    }
6638
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7540
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6639 7541
       unset( $this->compix['INDEX'] );
6640 7542
       $argType = strtolower( $arg1 );
6641
-      if( !$arg2 )
6642
-        $index = $this->compix[$argType] =
7543
+      if( !$arg2 ) {
7544
+              $index = $this->compix[$argType] =
6643 7545
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6644
-      else
6645
-        $index = (int) $arg2;
7546
+      } else {
7547
+              $index = (int) $arg2;
7548
+      }
6646 7549
     }
6647 7550
     $index  -= 1;
6648 7551
     $ckeys = array_keys( $this->components );
6649
-    if( !empty( $index) && ( $index > end( $ckeys )))
6650
-      return FALSE;
7552
+    if( !empty( $index) && ( $index > end( $ckeys ))) {
7553
+          return FALSE;
7554
+    }
6651 7555
     $cix2gC = 0;
6652 7556
     foreach( $this->components as $cix => $component ) {
6653
-      if( empty( $component )) continue;
7557
+      if( empty( $component )) {
7558
+          continue;
7559
+      }
6654 7560
       unset( $component->propix );
6655
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
6656
-        return $component->copy();
6657
-      elseif( $argType == $component->objName ) {
6658
-         if( $index == $cix2gC )
6659
-           return $component->copy();
7561
+      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
7562
+              return $component->copy();
7563
+      } elseif( $argType == $component->objName ) {
7564
+         if( $index == $cix2gC ) {
7565
+                    return $component->copy();
7566
+         }
6660 7567
          $cix2gC++;
6661
-      }
6662
-      elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
7568
+      } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6663 7569
         unset( $component->propix );
6664 7570
         return $component->copy();
6665 7571
       }
@@ -6690,9 +7596,12 @@  discard block
 block discarded – undo
6690 7596
  * @return bool
6691 7597
  */
6692 7598
   function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6693
-    if( !isset( $this->components )) return FALSE;
6694
-    if( '' >= $component->getConfig( 'language'))
6695
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
7599
+    if( !isset( $this->components )) {
7600
+        return FALSE;
7601
+    }
7602
+    if( '' >= $component->getConfig( 'language')) {
7603
+          $component->setConfig( 'language',  $this->getConfig( 'language' ));
7604
+    }
6696 7605
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6697 7606
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6698 7607
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6711,27 +7620,26 @@  discard block
 block discarded – undo
6711 7620
     if ( ctype_digit( (string) $arg1 )) {
6712 7621
       $argType = 'INDEX';
6713 7622
       $index   = (int) $arg1 - 1;
6714
-    }
6715
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7623
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6716 7624
       $argType = strtolower( $arg1 );
6717 7625
       $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6718 7626
     }
6719 7627
     $cix2sC = 0;
6720 7628
     foreach ( $this->components as $cix => $component2 ) {
6721
-      if( empty( $component2 )) continue;
7629
+      if( empty( $component2 )) {
7630
+          continue;
7631
+      }
6722 7632
       unset( $component2->propix );
6723 7633
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6724 7634
         $this->components[$cix] = $component->copy();
6725 7635
         return TRUE;
6726
-      }
6727
-      elseif( $argType == $component2->objName ) {
7636
+      } elseif( $argType == $component2->objName ) {
6728 7637
         if( $index == $cix2sC ) {
6729 7638
           $this->components[$cix] = $component->copy();
6730 7639
           return TRUE;
6731 7640
         }
6732 7641
         $cix2sC++;
6733
-      }
6734
-      elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
7642
+      } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6735 7643
         $this->components[$cix] = $component->copy();
6736 7644
         return TRUE;
6737 7645
       }
@@ -6750,9 +7658,12 @@  discard block
 block discarded – undo
6750 7658
   function createSubComponent() {
6751 7659
     $output = null;
6752 7660
     foreach( $this->components as $component ) {
6753
-      if( empty( $component )) continue;
6754
-      if( '' >= $component->getConfig( 'language'))
6755
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
7661
+      if( empty( $component )) {
7662
+          continue;
7663
+      }
7664
+      if( '' >= $component->getConfig( 'language')) {
7665
+              $component->setConfig( 'language',  $this->getConfig( 'language' ));
7666
+      }
6756 7667
       $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6757 7668
       $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6758 7669
       $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6790,16 +7701,18 @@  discard block
 block discarded – undo
6790 7701
     $string = null;
6791 7702
     while( $strlen > 75 ) {
6792 7703
        $breakAtChar = 75;
6793
-       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6794
-         $breakAtChar = $breakAtChar - 1;
7704
+       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) {
7705
+                $breakAtChar = $breakAtChar - 1;
7706
+       }
6795 7707
        $string .= substr( $tmp, 0, $breakAtChar );
6796 7708
        $string .= $this->nl;
6797 7709
        $tmp     = ' '.substr( $tmp, $breakAtChar );
6798 7710
        $strlen  = strlen( $tmp );
6799 7711
     } // while
6800 7712
     $string .= rtrim( $tmp ); // the rest
6801
-    if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6802
-      $string .= $this->nl;
7713
+    if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) {
7714
+          $string .= $this->nl;
7715
+    }
6803 7716
     return $string;
6804 7717
   }
6805 7718
 /**
@@ -6820,27 +7733,33 @@  discard block
 block discarded – undo
6820 7733
         $pos = 0;
6821 7734
         while( $pos <= strlen( $string )) {
6822 7735
           $pos = strpos( $string, "\\", $pos );
6823
-          if( FALSE === $pos )
6824
-            break;
7736
+          if( FALSE === $pos ) {
7737
+                      break;
7738
+          }
6825 7739
           if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6826 7740
             $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6827 7741
             $pos += 1;
6828 7742
           }
6829 7743
           $pos += 1;
6830 7744
         }
6831
-        if( FALSE !== strpos( $string, '"' ))
6832
-          $string = str_replace('"',   "'",       $string);
6833
-        if( FALSE !== strpos( $string, ',' ))
6834
-          $string = str_replace(',',   '\,',      $string);
6835
-        if( FALSE !== strpos( $string, ';' ))
6836
-          $string = str_replace(';',   '\;',      $string);
6837
-        if( FALSE !== strpos( $string, "\r\n" ))
6838
-          $string = str_replace( "\r\n", '\n',    $string);
6839
-        elseif( FALSE !== strpos( $string, "\r" ))
6840
-          $string = str_replace( "\r", '\n',      $string);
6841
-        if( FALSE !== strpos( $string, '\N' ))
6842
-          $string = str_replace( '\N', '\n',      $string);
6843
-//        if( FALSE !== strpos( $string, $this->nl ))
7745
+        if( FALSE !== strpos( $string, '"' )) {
7746
+                  $string = str_replace('"',   "'",       $string);
7747
+        }
7748
+        if( FALSE !== strpos( $string, ',' )) {
7749
+                  $string = str_replace(',',   '\,',      $string);
7750
+        }
7751
+        if( FALSE !== strpos( $string, ';' )) {
7752
+                  $string = str_replace(';',   '\;',      $string);
7753
+        }
7754
+        if( FALSE !== strpos( $string, "\r\n" )) {
7755
+                  $string = str_replace( "\r\n", '\n',    $string);
7756
+        } elseif( FALSE !== strpos( $string, "\r" )) {
7757
+                  $string = str_replace( "\r", '\n',      $string);
7758
+        }
7759
+        if( FALSE !== strpos( $string, '\N' )) {
7760
+                  $string = str_replace( '\N', '\n',      $string);
7761
+        }
7762
+        //        if( FALSE !== strpos( $string, $this->nl ))
6844 7763
           $string = str_replace( $this->nl, '\n', $string);
6845 7764
         break;
6846 7765
     }
@@ -6993,8 +7912,9 @@  discard block
 block discarded – undo
6993 7912
     $component    .= $this->createSubComponent();
6994 7913
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
6995 7914
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
6996
-      foreach( $this->xcaldecl as $localxcaldecl )
6997
-        $xcaldecl[] = $localxcaldecl;
7915
+      foreach( $this->xcaldecl as $localxcaldecl ) {
7916
+              $xcaldecl[] = $localxcaldecl;
7917
+      }
6998 7918
     }
6999 7919
     return $component;
7000 7920
   }
@@ -7132,8 +8052,9 @@  discard block
 block discarded – undo
7132 8052
     $component    .= $this->createSubComponent();
7133 8053
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7134 8054
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7135
-      foreach( $this->xcaldecl as $localxcaldecl )
7136
-        $xcaldecl[] = $localxcaldecl;
8055
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8056
+              $xcaldecl[] = $localxcaldecl;
8057
+      }
7137 8058
     }
7138 8059
     return $component;
7139 8060
   }
@@ -7242,8 +8163,9 @@  discard block
 block discarded – undo
7242 8163
     $component .= $this->createXprop();
7243 8164
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7244 8165
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7245
-      foreach( $this->xcaldecl as $localxcaldecl )
7246
-        $xcaldecl[] = $localxcaldecl;
8166
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8167
+              $xcaldecl[] = $localxcaldecl;
8168
+      }
7247 8169
     }
7248 8170
     return $component;
7249 8171
   }
@@ -7318,8 +8240,9 @@  discard block
 block discarded – undo
7318 8240
     $component .= $this->createXprop();
7319 8241
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7320 8242
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7321
-      foreach( $this->xcaldecl as $localxcaldecl )
7322
-        $xcaldecl[] = $localxcaldecl;
8243
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8244
+              $xcaldecl[] = $localxcaldecl;
8245
+      }
7323 8246
     }
7324 8247
     return $component;
7325 8248
   }
@@ -7419,10 +8342,11 @@  discard block
 block discarded – undo
7419 8342
  * @return void
7420 8343
  */
7421 8344
   function vtimezone( $timezonetype=FALSE ) {
7422
-    if( !$timezonetype )
7423
-      $this->timezonetype = 'VTIMEZONE';
7424
-    else
7425
-      $this->timezonetype = strtoupper( $timezonetype );
8345
+    if( !$timezonetype ) {
8346
+          $this->timezonetype = 'VTIMEZONE';
8347
+    } else {
8348
+          $this->timezonetype = strtoupper( $timezonetype );
8349
+    }
7426 8350
     $this->calendarComponent();
7427 8351
 
7428 8352
     $this->comment         = '';
@@ -7464,8 +8388,9 @@  discard block
 block discarded – undo
7464 8388
     $component    .= $this->createSubComponent();
7465 8389
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7466 8390
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7467
-      foreach( $this->xcaldecl as $localxcaldecl )
7468
-        $xcaldecl[] = $localxcaldecl;
8391
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8392
+              $xcaldecl[] = $localxcaldecl;
8393
+      }
7469 8394
     }
7470 8395
     return $component;
7471 8396
   }
Please login to merge, or discard this patch.
Indentation   +3356 added lines, -3357 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 */
46 46
             /* only for phpversion 5.x, date management, default timezone setting */
47 47
 if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) {
48
-  date_default_timezone_set( 'Europe/Stockholm' );
48
+    date_default_timezone_set( 'Europe/Stockholm' );
49 49
             /* version string, do NOT remove!! */
50 50
 define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' );
51 51
 /*********************************************************************************/
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
  */
59 59
 class vcalendar {
60 60
             //  calendar property variables
61
-  var $calscale;
62
-  var $method;
63
-  var $prodid;
64
-  var $version;
65
-  var $xprop;
61
+    var $calscale;
62
+    var $method;
63
+    var $prodid;
64
+    var $version;
65
+    var $xprop;
66 66
             //  container for calendar components
67
-  var $components;
67
+    var $components;
68 68
             //  component config variables
69
-  var $allowEmpty;
70
-  var $unique_id;
71
-  var $language;
72
-  var $directory;
73
-  var $filename;
74
-  var $url;
75
-  var $delimiter;
76
-  var $nl;
77
-  var $format;
69
+    var $allowEmpty;
70
+    var $unique_id;
71
+    var $language;
72
+    var $directory;
73
+    var $filename;
74
+    var $url;
75
+    var $delimiter;
76
+    var $nl;
77
+    var $format;
78 78
             //  component internal variables
79
-  var $attributeDelimiter;
80
-  var $valueInit;
79
+    var $attributeDelimiter;
80
+    var $valueInit;
81 81
             //  component xCal declaration container
82
-  var $xcaldecl;
82
+    var $xcaldecl;
83 83
 /*
84 84
  * constructor for calendar object
85 85
  *
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
  * @since 2.2.13 - 2007-12-30
88 88
  * @return void
89 89
  */
90
-  function vcalendar () {
90
+    function vcalendar () {
91 91
     $this->_makeVersion();
92 92
     $this->calscale   = null;
93 93
     $this->method     = null;
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
     $this->prodid     = null;
96 96
     $this->xprop      = array();
97 97
 /**
98
- *   language = <Text identifying a language, as defined in [RFC 1766]>
99
- */
98
+     *   language = <Text identifying a language, as defined in [RFC 1766]>
99
+     */
100 100
     if( defined( 'ICAL_LANG' ))
101
-      $this->setConfig( 'language', ICAL_LANG );
101
+        $this->setConfig( 'language', ICAL_LANG );
102 102
     $this->setConfig( 'allowEmpty', TRUE );
103 103
     $this->setConfig( 'nl',         "\n" );
104 104
     $this->setConfig( 'format',     'iCal');
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     $this->setConfig( 'delimiter',  DIRECTORY_SEPARATOR );
109 109
     $this->xcaldecl   = array();
110 110
     $this->components = array();
111
-  }
111
+    }
112 112
 /*********************************************************************************/
113 113
 /**
114 114
  * Property Name: CALSCALE
@@ -120,29 +120,29 @@  discard block
 block discarded – undo
120 120
  * @since 2.4.8 - 2008-10-21
121 121
  * @return string
122 122
  */
123
-  function createCalscale() {
123
+    function createCalscale() {
124 124
     if( empty( $this->calscale )) return FALSE;
125 125
     switch( $this->format ) {
126
-      case 'xcal':
126
+        case 'xcal':
127 127
         return ' calscale="'.$this->calscale.'"'.$this->nl;
128 128
         break;
129
-      default:
129
+        default:
130 130
         return 'CALSCALE:'.$this->calscale.$this->nl;
131 131
         break;
132 132
     }
133
-  }
133
+    }
134 134
 /**
135
- * set calendar property calscale
136
- *
137
- * @author Kjell-Inge Gustafsson <[email protected]>
138
- * @since 2.4.8 - 2008-10-21
139
- * @param string $value
140
- * @return void
141
- */
142
-  function setCalscale( $value ) {
135
+     * set calendar property calscale
136
+     *
137
+     * @author Kjell-Inge Gustafsson <[email protected]>
138
+     * @since 2.4.8 - 2008-10-21
139
+     * @param string $value
140
+     * @return void
141
+     */
142
+    function setCalscale( $value ) {
143 143
     if( empty( $value )) return FALSE;
144 144
     $this->calscale = $value;
145
-  }
145
+    }
146 146
 /*********************************************************************************/
147 147
 /**
148 148
  * Property Name: METHOD
@@ -154,30 +154,30 @@  discard block
 block discarded – undo
154 154
  * @since 0.9.7 - 2006-11-20
155 155
  * @return string
156 156
  */
157
-  function createMethod() {
157
+    function createMethod() {
158 158
     if( empty( $this->method )) return FALSE;
159 159
     switch( $this->format ) {
160
-      case 'xcal':
160
+        case 'xcal':
161 161
         return ' method="'.$this->method.'"'.$this->nl;
162 162
         break;
163
-      default:
163
+        default:
164 164
         return 'METHOD:'.$this->method.$this->nl;
165 165
         break;
166 166
     }
167
-  }
167
+    }
168 168
 /**
169
- * set calendar property method
170
- *
171
- * @author Kjell-Inge Gustafsson <[email protected]>
172
- * @since 2.4.8 - 2008-20-23
173
- * @param string $value
174
- * @return bool
175
- */
176
-  function setMethod( $value ) {
169
+     * set calendar property method
170
+     *
171
+     * @author Kjell-Inge Gustafsson <[email protected]>
172
+     * @since 2.4.8 - 2008-20-23
173
+     * @param string $value
174
+     * @return bool
175
+     */
176
+    function setMethod( $value ) {
177 177
     if( empty( $value )) return FALSE;
178 178
     $this->method = $value;
179 179
     return TRUE;
180
-  }
180
+    }
181 181
 /*********************************************************************************/
182 182
 /**
183 183
  * Property Name: PRODID
@@ -193,44 +193,44 @@  discard block
 block discarded – undo
193 193
  * @since 0.9.7 - 2006-11-20
194 194
  * @return string
195 195
  */
196
-  function createProdid() {
196
+    function createProdid() {
197 197
     if( !isset( $this->prodid ))
198
-      $this->_makeProdid();
198
+        $this->_makeProdid();
199 199
     switch( $this->format ) {
200
-      case 'xcal':
200
+        case 'xcal':
201 201
         return ' prodid="'.$this->prodid.'"'.$this->nl;
202 202
         break;
203
-      default:
203
+        default:
204 204
         return 'PRODID:'.$this->prodid.$this->nl;
205 205
         break;
206 206
     }
207
-  }
207
+    }
208 208
 /**
209
- * make default value for calendar prodid
210
- *
211
- * @author Kjell-Inge Gustafsson <[email protected]>
212
- * @since 0.3.0 - 2006-08-10
213
- * @return void
214
- */
215
-  function _makeProdid() {
209
+     * make default value for calendar prodid
210
+     *
211
+     * @author Kjell-Inge Gustafsson <[email protected]>
212
+     * @since 0.3.0 - 2006-08-10
213
+     * @return void
214
+     */
215
+    function _makeProdid() {
216 216
     $this->prodid  = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language );
217
-  }
217
+    }
218 218
 /**
219
- * Conformance: The property MUST be specified once in an iCalendar object.
220
- * Description: The vendor of the implementation SHOULD assure that this
221
- * is a globally unique identifier; using some technique such as an FPI
222
- * value, as defined in [ISO 9070].
223
- */
219
+     * Conformance: The property MUST be specified once in an iCalendar object.
220
+     * Description: The vendor of the implementation SHOULD assure that this
221
+     * is a globally unique identifier; using some technique such as an FPI
222
+     * value, as defined in [ISO 9070].
223
+     */
224 224
 /**
225
- * make default unique_id for calendar prodid
226
- *
227
- * @author Kjell-Inge Gustafsson <[email protected]>
228
- * @since 0.3.0 - 2006-08-10
229
- * @return void
230
- */
231
-  function _makeUnique_id() {
225
+     * make default unique_id for calendar prodid
226
+     *
227
+     * @author Kjell-Inge Gustafsson <[email protected]>
228
+     * @since 0.3.0 - 2006-08-10
229
+     * @return void
230
+     */
231
+    function _makeUnique_id() {
232 232
     $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
233
-  }
233
+    }
234 234
 /*********************************************************************************/
235 235
 /**
236 236
  * Property Name: VERSION
@@ -239,47 +239,46 @@  discard block
 block discarded – undo
239 239
  */
240 240
 /**
241 241
  * creates formatted output for calendar property version
242
-
243 242
  *
244 243
  * @author Kjell-Inge Gustafsson <[email protected]>
245 244
  * @since 0.9.7 - 2006-11-20
246 245
  * @return string
247 246
  */
248
-  function createVersion() {
247
+    function createVersion() {
249 248
     if( empty( $this->version ))
250
-      $this->_makeVersion();
249
+        $this->_makeVersion();
251 250
     switch( $this->format ) {
252
-      case 'xcal':
251
+        case 'xcal':
253 252
         return ' version="'.$this->version.'"'.$this->nl;
254 253
         break;
255
-      default:
254
+        default:
256 255
         return 'VERSION:'.$this->version.$this->nl;
257 256
         break;
258 257
     }
259
-  }
258
+    }
260 259
 /**
261
- * set default calendar version
262
- *
263
- * @author Kjell-Inge Gustafsson <[email protected]>
264
- * @since 0.3.0 - 2006-08-10
265
- * @return void
266
- */
267
-  function _makeVersion() {
260
+     * set default calendar version
261
+     *
262
+     * @author Kjell-Inge Gustafsson <[email protected]>
263
+     * @since 0.3.0 - 2006-08-10
264
+     * @return void
265
+     */
266
+    function _makeVersion() {
268 267
     $this->version = '2.0';
269
-  }
268
+    }
270 269
 /**
271
- * set calendar version
272
- *
273
- * @author Kjell-Inge Gustafsson <[email protected]>
274
- * @since 2.4.8 - 2008-10-23
275
- * @param string $value
276
- * @return void
277
- */
278
-  function setVersion( $value ) {
270
+     * set calendar version
271
+     *
272
+     * @author Kjell-Inge Gustafsson <[email protected]>
273
+     * @since 2.4.8 - 2008-10-23
274
+     * @param string $value
275
+     * @return void
276
+     */
277
+    function setVersion( $value ) {
279 278
     if( empty( $value )) return FALSE;
280 279
     $this->version = $value;
281 280
     return TRUE;
282
-  }
281
+    }
283 282
 /*********************************************************************************/
284 283
 /**
285 284
  * Property Name: x-prop
@@ -291,44 +290,44 @@  discard block
 block discarded – undo
291 290
  * @since 2.4.11 - 2008-11-03
292 291
  * @return string
293 292
  */
294
-  function createXprop() {
293
+    function createXprop() {
295 294
     if( 'xcal' == $this->format )
296
-      return false;
295
+        return false;
297 296
     if( 0 >= count( $this->xprop ))
298
-      return;
297
+        return;
299 298
     $output = null;
300 299
     $toolbox = new calendarComponent();
301 300
     $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
302 301
     $toolbox->setConfig( 'nl',       $this->getConfig( 'nl' ));
303 302
     $toolbox->_createFormat(         $this->getConfig( 'format' ));
304 303
     foreach( $this->xprop as $label => $xpropPart ) {
305
-      if( empty( $xpropPart['value'] )) {
304
+        if( empty( $xpropPart['value'] )) {
306 305
         $output  .= $toolbox->_createElement( $label );
307 306
         continue;
308
-      }
309
-      $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
310
-      if( is_array( $xpropPart['value'] )) {
307
+        }
308
+        $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
309
+        if( is_array( $xpropPart['value'] )) {
311 310
         foreach( $xpropPart['value'] as $pix => $theXpart )
312
-          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
311
+            $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
313 312
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
314
-      }
315
-      else
313
+        }
314
+        else
316 315
         $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
317
-      $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
316
+        $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
318 317
     }
319 318
     return $output;
320
-  }
319
+    }
321 320
 /**
322
- * set calendar property x-prop
323
- *
324
- * @author Kjell-Inge Gustafsson <[email protected]>
325
- * @since 2.4.11 - 2008-11-04
326
- * @param string $label
327
- * @param string $value
328
- * @param array $params optional
329
- * @return bool
330
- */
331
-  function setXprop( $label, $value, $params=FALSE ) {
321
+     * set calendar property x-prop
322
+     *
323
+     * @author Kjell-Inge Gustafsson <[email protected]>
324
+     * @since 2.4.11 - 2008-11-04
325
+     * @param string $label
326
+     * @param string $value
327
+     * @param array $params optional
328
+     * @return bool
329
+     */
330
+    function setXprop( $label, $value, $params=FALSE ) {
332 331
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
333 332
     if( empty( $label )) return FALSE;
334 333
     $xprop           = array( 'value' => $value );
@@ -337,7 +336,7 @@  discard block
 block discarded – undo
337 336
     if( !is_array( $this->xprop )) $this->xprop = array();
338 337
     $this->xprop[strtoupper( $label )] = $xprop;
339 338
     return TRUE;
340
-  }
339
+    }
341 340
 /*********************************************************************************/
342 341
 /**
343 342
  * delete calendar property value
@@ -348,131 +347,131 @@  discard block
 block discarded – undo
348 347
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
349 348
  * @return bool, if successfull delete
350 349
  */
351
-  function deleteProperty( $propName, $propix=FALSE ) {
350
+    function deleteProperty( $propName, $propix=FALSE ) {
352 351
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
353 352
     if( !$propix )
354
-      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
353
+        $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
355 354
     $this->propdelix[$propName] = --$propix;
356 355
     $return = FALSE;
357 356
     switch( $propName ) {
358
-      case 'CALSCALE':
357
+        case 'CALSCALE':
359 358
         if( isset( $this->calscale )) {
360
-          $this->calscale = null;
361
-          $return = TRUE;
359
+            $this->calscale = null;
360
+            $return = TRUE;
362 361
         }
363 362
         break;
364
-      case 'METHOD':
363
+        case 'METHOD':
365 364
         if( isset( $this->method )) {
366
-          $this->method   = null;
367
-          $return = TRUE;
365
+            $this->method   = null;
366
+            $return = TRUE;
368 367
         }
369 368
         break;
370
-      default:
369
+        default:
371 370
         $reduced = array();
372 371
         if( $propName != 'X-PROP' ) {
373
-          if( !isset( $this->xprop[$propName] )) return FALSE;
374
-          foreach( $this->xprop as $k => $a ) {
372
+            if( !isset( $this->xprop[$propName] )) return FALSE;
373
+            foreach( $this->xprop as $k => $a ) {
375 374
             if(( $k != $propName ) && !empty( $a ))
376
-              $reduced[$k] = $a;
377
-          }
375
+                $reduced[$k] = $a;
376
+            }
378 377
         }
379 378
         else {
380
-          if( count( $this->xprop ) <= $propix )  return FALSE;
381
-          $xpropno = 0;
382
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
379
+            if( count( $this->xprop ) <= $propix )  return FALSE;
380
+            $xpropno = 0;
381
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
383 382
             if( $propix != $xpropno )
384
-              $reduced[$xpropkey] = $xpropvalue;
383
+                $reduced[$xpropkey] = $xpropvalue;
385 384
             $xpropno++;
386
-          }
385
+            }
387 386
         }
388 387
         $this->xprop = $reduced;
389 388
         return TRUE;
390 389
     }
391 390
     return $return;
392
-  }
391
+    }
393 392
 /**
394
- * get calendar property value/params
395
- *
396
- * @author Kjell-Inge Gustafsson <[email protected]>
397
- * @since 2.5.1 - 2008-11-02
398
- * @param string $propName, optional
399
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
400
- * @param bool $inclParam=FALSE
401
- * @return mixed
402
- */
403
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
393
+     * get calendar property value/params
394
+     *
395
+     * @author Kjell-Inge Gustafsson <[email protected]>
396
+     * @since 2.5.1 - 2008-11-02
397
+     * @param string $propName, optional
398
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
399
+     * @param bool $inclParam=FALSE
400
+     * @return mixed
401
+     */
402
+    function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
404 403
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
405 404
     if( 'X-PROP' == $propName ) {
406
-      if( !$propix )
405
+        if( !$propix )
407 406
         $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
408
-      $this->propix[$propName] = --$propix;
407
+        $this->propix[$propName] = --$propix;
409 408
     }
410 409
     switch( $propName ) {
411
-      case 'CALSCALE':
410
+        case 'CALSCALE':
412 411
         return ( !empty( $this->calscale )) ? $this->calscale : null;
413 412
         break;
414
-      case 'METHOD':
413
+        case 'METHOD':
415 414
         return ( !empty( $this->method )) ? $this->method : null;
416 415
         break;
417
-      case 'PRODID':
416
+        case 'PRODID':
418 417
         if( empty( $this->prodid ))
419
-          $this->_makeProdid();
418
+            $this->_makeProdid();
420 419
         return $this->prodid;
421 420
         break;
422
-      case 'VERSION':
421
+        case 'VERSION':
423 422
         return ( !empty( $this->version )) ? $this->version : null;
424 423
         break;
425
-      default:
424
+        default:
426 425
         if( $propName != 'X-PROP' ) {
427
-          if( !isset( $this->xprop[$propName] )) return FALSE;
428
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
426
+            if( !isset( $this->xprop[$propName] )) return FALSE;
427
+            return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
429 428
                                 : array( $propName, $this->xprop[$propName]['value'] );
430 429
         }
431 430
         else {
432
-          if( empty( $this->xprop )) return FALSE;
433
-          $xpropno = 0;
434
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
431
+            if( empty( $this->xprop )) return FALSE;
432
+            $xpropno = 0;
433
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
435 434
             if( $propix == $xpropno )
436
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
435
+                return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
437 436
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
438 437
             else
439
-              $xpropno++;
440
-          }
441
-          return FALSE; // not found ??
438
+                $xpropno++;
439
+            }
440
+            return FALSE; // not found ??
442 441
         }
443 442
     }
444 443
     return FALSE;
445
-  }
444
+    }
446 445
 /**
447
- * general vcalendar property setting
448
- *
449
- * @author Kjell-Inge Gustafsson <[email protected]>
450
- * @since 2.2.13 - 2007-11-04
451
- * @param mixed $args variable number of function arguments,
452
- *                    first argument is ALWAYS component name,
453
- *                    second ALWAYS component value!
454
- * @return bool
455
- */
456
-  function setProperty () {
446
+     * general vcalendar property setting
447
+     *
448
+     * @author Kjell-Inge Gustafsson <[email protected]>
449
+     * @since 2.2.13 - 2007-11-04
450
+     * @param mixed $args variable number of function arguments,
451
+     *                    first argument is ALWAYS component name,
452
+     *                    second ALWAYS component value!
453
+     * @return bool
454
+     */
455
+    function setProperty () {
457 456
     $numargs    = func_num_args();
458 457
     if( 1 > $numargs )
459
-      return FALSE;
458
+        return FALSE;
460 459
     $arglist    = func_get_args();
461 460
     $arglist[0] = strtoupper( $arglist[0] );
462 461
     switch( $arglist[0] ) {
463
-      case 'CALSCALE':
462
+        case 'CALSCALE':
464 463
         return $this->setCalscale( $arglist[1] );
465
-      case 'METHOD':
464
+        case 'METHOD':
466 465
         return $this->setMethod( $arglist[1] );
467
-      case 'VERSION':
466
+        case 'VERSION':
468 467
         return $this->setVersion( $arglist[1] );
469
-      default:
468
+        default:
470 469
         if( !isset( $arglist[1] )) $arglist[1] = null;
471 470
         if( !isset( $arglist[2] )) $arglist[2] = null;
472 471
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
473 472
     }
474 473
     return FALSE;
475
-  }
474
+    }
476 475
 /*********************************************************************************/
477 476
 /**
478 477
  * get vcalendar config values or * calendar components
@@ -482,180 +481,180 @@  discard block
 block discarded – undo
482 481
  * @param string $config
483 482
  * @return value
484 483
  */
485
-  function getConfig( $config ) {
484
+    function getConfig( $config ) {
486 485
     switch( strtoupper( $config )) {
487
-      case 'ALLOWEMPTY':
486
+        case 'ALLOWEMPTY':
488 487
         return $this->allowEmpty;
489 488
         break;
490
-      case 'COMPSINFO':
489
+        case 'COMPSINFO':
491 490
         unset( $this->compix );
492 491
         $info = array();
493 492
         foreach( $this->components as $cix => $component ) {
494
-          if( empty( $component )) continue;
495
-          unset( $component->propix );
496
-          $info[$cix]['ordno'] = $cix + 1;
497
-          $info[$cix]['type']  = $component->objName;
498
-          $info[$cix]['uid']   = $component->getProperty( 'uid' );
499
-          $info[$cix]['props'] = $component->getConfig( 'propinfo' );
500
-          $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
501
-          unset( $component->propix );
493
+            if( empty( $component )) continue;
494
+            unset( $component->propix );
495
+            $info[$cix]['ordno'] = $cix + 1;
496
+            $info[$cix]['type']  = $component->objName;
497
+            $info[$cix]['uid']   = $component->getProperty( 'uid' );
498
+            $info[$cix]['props'] = $component->getConfig( 'propinfo' );
499
+            $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
500
+            unset( $component->propix );
502 501
         }
503 502
         return $info;
504 503
         break;
505
-      case 'DELIMITER':
504
+        case 'DELIMITER':
506 505
         return $this->delimiter;
507 506
         break;
508
-      case 'DIRECTORY':
507
+        case 'DIRECTORY':
509 508
         if( empty( $this->directory ))
510
-          $this->directory = '.';
509
+            $this->directory = '.';
511 510
         return $this->directory;
512 511
         break;
513
-      case 'DIRFILE':
512
+        case 'DIRFILE':
514 513
         return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' );
515 514
         break;
516
-      case 'FILEINFO':
515
+        case 'FILEINFO':
517 516
         return array( $this->getConfig( 'directory' )
518 517
                     , $this->getConfig( 'filename' )
519 518
                     , $this->getConfig( 'filesize' ));
520 519
         break;
521
-      case 'FILENAME':
520
+        case 'FILENAME':
522 521
         if( empty( $this->filename )) {
523
-          if( 'xcal' == $this->format )
522
+            if( 'xcal' == $this->format )
524 523
             $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
525
-          else
524
+            else
526 525
             $this->filename = date( 'YmdHis' ).'.ics';
527 526
         }
528 527
         return $this->filename;
529 528
         break;
530
-      case 'FILESIZE':
529
+        case 'FILESIZE':
531 530
         $size    = 0;
532 531
         if( empty( $this->url )) {
533
-          $dirfile = $this->getConfig( 'dirfile' );
534
-          if( FALSE === ( $size = filesize( $dirfile )))
532
+            $dirfile = $this->getConfig( 'dirfile' );
533
+            if( FALSE === ( $size = filesize( $dirfile )))
535 534
             $size = 0;
536
-          clearstatcache();
535
+            clearstatcache();
537 536
         }
538 537
         return $size;
539 538
         break;
540
-      case 'FORMAT':
539
+        case 'FORMAT':
541 540
         return $this->format;
542 541
         break;
543
-      case 'LANGUAGE':
542
+        case 'LANGUAGE':
544 543
          /* get language for calendar component as defined in [RFC 1766] */
545 544
         return $this->language;
546 545
         break;
547
-      case 'NL':
546
+        case 'NL':
548 547
       case 'NEWLINECHAR':
549 548
         return $this->nl;
550 549
         break;
551
-      case 'UNIQUE_ID':
550
+        case 'UNIQUE_ID':
552 551
         return $this->unique_id;
553 552
         break;
554
-      case 'URL':
553
+        case 'URL':
555 554
         if( !empty( $this->url ))
556
-          return $this->url;
555
+            return $this->url;
557 556
         else
558
-          return FALSE;
557
+            return FALSE;
559 558
         break;
560 559
     }
561
-  }
560
+    }
562 561
 /**
563
- * general vcalendar config setting
564
- *
565
- * @author Kjell-Inge Gustafsson <[email protected]>
566
- * @since 2.4.8 - 2008-10-24
567
- * @param string $config
568
- * @param string $value
569
- * @return void
570
- */
571
-  function setConfig( $config, $value ) {
562
+     * general vcalendar config setting
563
+     *
564
+     * @author Kjell-Inge Gustafsson <[email protected]>
565
+     * @since 2.4.8 - 2008-10-24
566
+     * @param string $config
567
+     * @param string $value
568
+     * @return void
569
+     */
570
+    function setConfig( $config, $value ) {
572 571
     $res = FALSE;
573 572
     switch( strtoupper( $config )) {
574
-      case 'ALLOWEMPTY':
573
+        case 'ALLOWEMPTY':
575 574
         $this->allowEmpty = $value;
576 575
         $subcfg  = array( 'ALLOWEMPTY' => $value );
577 576
         $res = TRUE;
578 577
         break;
579
-      case 'DELIMITER':
578
+        case 'DELIMITER':
580 579
         $this->delimiter = $value;
581 580
         return TRUE;
582 581
         break;
583
-      case 'DIRECTORY':
582
+        case 'DIRECTORY':
584 583
         $value   = trim( $value );
585 584
         $nl      = $this->getConfig('delimiter');
586 585
         if( $nl == substr( $value, ( 0 - strlen( $nl ))))
587
-          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
586
+            $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
588 587
         if( is_dir( $value )) {
589 588
             /* local directory */
590
-          clearstatcache();
591
-          $this->directory = $value;
592
-          $this->url       = null;
593
-          return TRUE;
589
+            clearstatcache();
590
+            $this->directory = $value;
591
+            $this->url       = null;
592
+            return TRUE;
594 593
         }
595 594
         else
596
-          return FALSE;
595
+            return FALSE;
597 596
         break;
598
-      case 'FILENAME':
597
+        case 'FILENAME':
599 598
         $value   = trim( $value );
600 599
         if( !empty( $this->url )) {
601 600
             /* remote directory+file - URL */
602
-          $this->filename = $value;
603
-          return TRUE;
601
+            $this->filename = $value;
602
+            return TRUE;
604 603
         }
605 604
         $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value;
606 605
         if( file_exists( $dirfile )) {
607 606
             /* local existing file */
608
-          if( is_readable( $dirfile ) || is_writable( $dirfile )) {
607
+            if( is_readable( $dirfile ) || is_writable( $dirfile )) {
609 608
             clearstatcache();
610 609
             $this->filename = $value;
611 610
             return TRUE;
612
-          }
613
-          else
611
+            }
612
+            else
614 613
             return FALSE;
615 614
         }
616 615
         elseif( FALSE !== touch( $dirfile )) {
617 616
             /* new local file created */
618
-          $this->filename = $value;
619
-          return TRUE;
617
+            $this->filename = $value;
618
+            return TRUE;
620 619
         }
621 620
         else
622
-          return FALSE;
621
+            return FALSE;
623 622
         break;
624
-      case 'FORMAT':
623
+        case 'FORMAT':
625 624
         $value   = trim( $value );
626 625
         if( 'xcal' == strtolower( $value )) {
627
-          $this->format             = 'xcal';
628
-          $this->attributeDelimiter = $this->nl;
629
-          $this->valueInit          = null;
626
+            $this->format             = 'xcal';
627
+            $this->attributeDelimiter = $this->nl;
628
+            $this->valueInit          = null;
630 629
         }
631 630
         else {
632
-          $this->format             = null;
633
-          $this->attributeDelimiter = ';';
634
-          $this->valueInit          = ':';
631
+            $this->format             = null;
632
+            $this->attributeDelimiter = ';';
633
+            $this->valueInit          = ':';
635 634
         }
636 635
         $subcfg  = array( 'FORMAT' => $value );
637 636
         $res = TRUE;
638 637
         break;
639
-      case 'LANGUAGE':
638
+        case 'LANGUAGE':
640 639
          // set language for calendar component as defined in [RFC 1766]
641 640
         $value   = trim( $value );
642 641
         $this->language = $value;
643 642
         $subcfg  = array( 'LANGUAGE' => $value );
644 643
         $res = TRUE;
645 644
         break;
646
-      case 'NL':
645
+        case 'NL':
647 646
       case 'NEWLINECHAR':
648 647
         $this->nl = $value;
649 648
         $subcfg  = array( 'NL' => $value );
650 649
         $res = TRUE;
651 650
         break;
652
-      case 'UNIQUE_ID':
651
+        case 'UNIQUE_ID':
653 652
         $value   = trim( $value );
654 653
         $this->unique_id = $value;
655 654
         $subcfg  = array( 'UNIQUE_ID' => $value );
656 655
         $res = TRUE;
657 656
         break;
658
-      case 'URL':
657
+        case 'URL':
659 658
             /* remote file - URL */
660 659
         $value     = trim( $value );
661 660
         $value     = str_replace( 'HTTP://',   'http://', $value );
@@ -669,17 +668,17 @@  discard block
 block discarded – undo
669 668
     }
670 669
     if( !$res ) return FALSE;
671 670
     if( isset( $subcfg ) && !empty( $this->components )) {
672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
671
+        foreach( $subcfg as $cfgkey => $cfgvalue ) {
673 672
         foreach( $this->components as $cix => $component ) {
674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
675
-          if( !$res )
673
+            $res = $component->setConfig( $cfgkey, $cfgvalue );
674
+            if( !$res )
676 675
             break 2;
677
-          $this->components[$cix] = $component->copy(); // PHP4 compliant
676
+            $this->components[$cix] = $component->copy(); // PHP4 compliant
677
+        }
678 678
         }
679
-      }
680 679
     }
681 680
     return $res;
682
-  }
681
+    }
683 682
 /*********************************************************************************/
684 683
 /**
685 684
  * add calendar component to container
@@ -691,129 +690,129 @@  discard block
 block discarded – undo
691 690
  * @param object $component calendar component
692 691
  * @return void
693 692
  */
694
-  function addComponent( $component ) {
693
+    function addComponent( $component ) {
695 694
     $this->setComponent( $component );
696
-  }
695
+    }
697 696
 /**
698
- * delete calendar component from container
699
- *
700
- * @author Kjell-Inge Gustafsson <[email protected]>
701
- * @since 2.4.10 - 2008-08-05
702
- * @param mixed $arg1 ordno / component type / component uid
703
- * @param mixed $arg2 optional, ordno if arg1 = component type
704
- * @return void
705
- */
706
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
697
+     * delete calendar component from container
698
+     *
699
+     * @author Kjell-Inge Gustafsson <[email protected]>
700
+     * @since 2.4.10 - 2008-08-05
701
+     * @param mixed $arg1 ordno / component type / component uid
702
+     * @param mixed $arg2 optional, ordno if arg1 = component type
703
+     * @return void
704
+     */
705
+    function deleteComponent( $arg1, $arg2=FALSE  ) {
707 706
     $argType = $index = null;
708 707
     if ( ctype_digit( (string) $arg1 )) {
709
-      $argType = 'INDEX';
710
-      $index   = (int) $arg1 - 1;
708
+        $argType = 'INDEX';
709
+        $index   = (int) $arg1 - 1;
711 710
     }
712 711
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
713
-      $argType = strtolower( $arg1 );
714
-      $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
712
+        $argType = strtolower( $arg1 );
713
+        $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
715 714
     }
716 715
     $cix1dC = 0;
717 716
     foreach ( $this->components as $cix => $component) {
718
-      if( empty( $component )) continue;
719
-      unset( $component->propix );
720
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
717
+        if( empty( $component )) continue;
718
+        unset( $component->propix );
719
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721 720
         unset( $this->components[$cix] );
722 721
         return TRUE;
723
-      }
724
-      elseif( $argType == $component->objName ) {
722
+        }
723
+        elseif( $argType == $component->objName ) {
725 724
         if( $index == $cix1dC ) {
726
-          unset( $this->components[$cix] );
727
-          return TRUE;
725
+            unset( $this->components[$cix] );
726
+            return TRUE;
728 727
         }
729 728
         $cix1dC++;
730
-      }
731
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
729
+        }
730
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732 731
         unset( $this->components[$cix] );
733 732
         return TRUE;
734
-      }
733
+        }
735 734
     }
736 735
     return FALSE;
737
-  }
736
+    }
738 737
 /**
739
- * get calendar component from container
740
- *
741
- * @author Kjell-Inge Gustafsson <[email protected]>
742
- * @since 2.4.10 - 2008-08-06
743
- * @param mixed $arg1 optional, ordno/component type/ component uid
744
- * @param mixed $arg2 optional, ordno if arg1 = component type
745
- * @return object
746
- */
747
-  function getComponent( $arg1=FALSE, $arg2=FALSE ) {
738
+     * get calendar component from container
739
+     *
740
+     * @author Kjell-Inge Gustafsson <[email protected]>
741
+     * @since 2.4.10 - 2008-08-06
742
+     * @param mixed $arg1 optional, ordno/component type/ component uid
743
+     * @param mixed $arg2 optional, ordno if arg1 = component type
744
+     * @return object
745
+     */
746
+    function getComponent( $arg1=FALSE, $arg2=FALSE ) {
748 747
     $index = $argType = null;
749 748
     if ( !$arg1 ) {
750
-      $argType = 'INDEX';
751
-      $index   = $this->compix['INDEX'] =
749
+        $argType = 'INDEX';
750
+        $index   = $this->compix['INDEX'] =
752 751
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
753 752
     }
754 753
     elseif ( ctype_digit( (string) $arg1 )) {
755
-      $argType = 'INDEX';
756
-      $index   = (int) $arg1;
757
-      unset( $this->compix );
754
+        $argType = 'INDEX';
755
+        $index   = (int) $arg1;
756
+        unset( $this->compix );
758 757
     }
759 758
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
760
-      unset( $this->compix['INDEX'] );
761
-      $argType = strtolower( $arg1 );
762
-      if( !$arg2 )
759
+        unset( $this->compix['INDEX'] );
760
+        $argType = strtolower( $arg1 );
761
+        if( !$arg2 )
763 762
         $index = $this->compix[$argType] =
764 763
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
765
-      else
764
+        else
766 765
         $index = (int) $arg2;
767 766
     }
768 767
     $index  -= 1;
769 768
     $ckeys =  array_keys( $this->components );
770 769
     if( !empty( $index) && ( $index > end(  $ckeys )))
771
-      return FALSE;
770
+        return FALSE;
772 771
     $cix1gC = 0;
773 772
     foreach ( $this->components as $cix => $component) {
774
-      if( empty( $component )) continue;
775
-      unset( $component->propix );
776
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
773
+        if( empty( $component )) continue;
774
+        unset( $component->propix );
775
+        if(( 'INDEX' == $argType ) && ( $index == $cix ))
777 776
         return $component->copy();
778
-      elseif( $argType == $component->objName ) {
779
-         if( $index == $cix1gC )
780
-           return $component->copy();
781
-         $cix1gC++;
782
-      }
783
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
777
+        elseif( $argType == $component->objName ) {
778
+            if( $index == $cix1gC )
779
+            return $component->copy();
780
+            $cix1gC++;
781
+        }
782
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
784 783
         unset( $component->propix );
785 784
         return $component->copy();
786
-      }
785
+        }
787 786
     }
788 787
             /* not found.. . */
789 788
     unset( $this->compix );
790 789
     return FALSE;
791
-  }
790
+    }
792 791
 /**
793
- * select components from calendar on date basis
794
- *
795
- * Ensure DTSTART is set for every component.
796
- * No date controls occurs.
797
- *
798
- * @author Kjell-Inge Gustafsson <[email protected]>
799
- * @since 2.4.16 - 2008-10-18
800
- * @param int $startY optional,  start Year, default current Year
801
- * @param int $startM optional,  start Month, default current Month
802
- * @param int $startD optional,  start Day, default current Day
803
- * @param int $endY optional,    end Year, default $startY
804
- * @param int $endY optional,    end Month, default $startM
805
- * @param int $endY optional,    end Day, default $startD
806
- * @param mixed $cType optional, calendar component type(-s), default FALSE=all else string/array type(-s)
807
- * @param bool $flat optional,   FALSE (default) => output : array[Year][Month][Day][]
808
- *                               TRUE => output : array[] (ignores split)
809
- * @param bool $any optional,    TRUE (default) - select component that take place within period
810
- *                               FALSE - only components that starts within period
811
- * @param bool $split optional,  TRUE (default) - one component copy every day it take place during the
812
- *                                       period (implies flat=FALSE)
813
- *                               FALSE - one occurance of component only in output array</tr>
814
- * @return array or FALSE
815
- */
816
-  function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
792
+     * select components from calendar on date basis
793
+     *
794
+     * Ensure DTSTART is set for every component.
795
+     * No date controls occurs.
796
+     *
797
+     * @author Kjell-Inge Gustafsson <[email protected]>
798
+     * @since 2.4.16 - 2008-10-18
799
+     * @param int $startY optional,  start Year, default current Year
800
+     * @param int $startM optional,  start Month, default current Month
801
+     * @param int $startD optional,  start Day, default current Day
802
+     * @param int $endY optional,    end Year, default $startY
803
+     * @param int $endY optional,    end Month, default $startM
804
+     * @param int $endY optional,    end Day, default $startD
805
+     * @param mixed $cType optional, calendar component type(-s), default FALSE=all else string/array type(-s)
806
+     * @param bool $flat optional,   FALSE (default) => output : array[Year][Month][Day][]
807
+     *                               TRUE => output : array[] (ignores split)
808
+     * @param bool $any optional,    TRUE (default) - select component that take place within period
809
+     *                               FALSE - only components that starts within period
810
+     * @param bool $split optional,  TRUE (default) - one component copy every day it take place during the
811
+     *                                       period (implies flat=FALSE)
812
+     *                               FALSE - one occurance of component only in output array</tr>
813
+     * @return array or FALSE
814
+     */
815
+    function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
817 816
             /* check  if empty calendar */
818 817
     if( 0 >= count( $this->components )) return FALSE;
819 818
             /* check default dates */
@@ -828,54 +827,54 @@  discard block
 block discarded – undo
828 827
             /* check component types */
829 828
     $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
830 829
     if( is_array( $cType )) {
831
-      foreach( $cType as $cix => $theType ) {
830
+        foreach( $cType as $cix => $theType ) {
832 831
         $cType[$cix] = $theType = strtolower( $theType );
833 832
         if( !in_array( $theType, $validTypes ))
834
-          $cType[$cix] = 'vevent';
835
-      }
836
-      $cType = array_unique( $cType );
833
+            $cType[$cix] = 'vevent';
834
+        }
835
+        $cType = array_unique( $cType );
837 836
     }
838 837
     elseif( !empty( $cType )) {
839
-      $cType = strtolower( $cType );
840
-      if( !in_array( $cType, $validTypes ))
838
+        $cType = strtolower( $cType );
839
+        if( !in_array( $cType, $validTypes ))
841 840
         $cType = array( 'vevent' );
842
-      else
841
+        else
843 842
         $cType = array( $cType );
844 843
     }
845 844
     else
846
-      $cType = $validTypes;
845
+        $cType = $validTypes;
847 846
     if( 0 >= count( $cType ))
848
-      $cType = $validTypes;
847
+        $cType = $validTypes;
849 848
             /* iterate components */
850 849
     $result = array();
851 850
     foreach ( $this->components as $cix => $component ) {
852
-      if( empty( $component )) continue;
853
-      unset( $component->propix, $start );
851
+        if( empty( $component )) continue;
852
+        unset( $component->propix, $start );
854 853
             /* deselect unvalid type components */
855
-      if( !in_array( $component->objName, $cType )) continue;
854
+        if( !in_array( $component->objName, $cType )) continue;
856 855
             /* deselect components without dtstart set */
857
-      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
858
-      $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
859
-      unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
860
-      $startWdate = $component->_date2timestamp( $start );
861
-      $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
856
+        if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
857
+        $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
858
+        unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
859
+        $startWdate = $component->_date2timestamp( $start );
860
+        $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
862 861
             /* get end date from dtend/due/duration properties */
863
-      $end = $component->getProperty( 'dtend' );
864
-      if( !empty( $end )) {
862
+        $end = $component->getProperty( 'dtend' );
863
+        if( !empty( $end )) {
865 864
         $dtendExist = TRUE;
866 865
         $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
867
-      }
868
-   // if( !empty($end))  echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
869
-      if( empty($end) && ( $component->objName == 'vtodo' )) {
866
+        }
867
+    // if( !empty($end))  echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
868
+        if( empty($end) && ( $component->objName == 'vtodo' )) {
870 869
         $end = $component->getProperty( 'due' );
871 870
         if( !empty( $end )) {
872
-          $dueExist = TRUE;
873
-          $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
871
+            $dueExist = TRUE;
872
+            $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
873
+        }
874
+    // if( !empty($end))  echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
874 875
         }
875
-   // if( !empty($end))  echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
876
-      }
877
-      if( !empty( $end ) && !isset( $end['hour'] )) {
878
-          /* a DTEND without time part regards an event that ends the day before,
876
+        if( !empty( $end ) && !isset( $end['hour'] )) {
877
+            /* a DTEND without time part regards an event that ends the day before,
879 878
              for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */
880 879
         $endAllDayEvent = TRUE;
881 880
         $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] );
@@ -884,575 +883,575 @@  discard block
 block discarded – undo
884 883
         $end['day']   = date( 'd', $endWdate );
885 884
         $end['hour']  = 23;
886 885
         $end['min']   = $end['sec'] = 59;
887
-   // if( !empty($end))  echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
888
-      }
889
-      if( empty( $end )) {
886
+    // if( !empty($end))  echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
887
+        }
888
+        if( empty( $end )) {
890 889
         $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
891 890
         if( !empty( $end ))
892
-          $durationExist = TRUE;
893
-   // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
894
-      }
895
-      if( empty( $end )) { // assume one day duration if missing end date
891
+            $durationExist = TRUE;
892
+    // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
893
+        }
894
+        if( empty( $end )) { // assume one day duration if missing end date
896 895
         $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
897
-   // if( isset($end))  echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
898
-      }
899
-      $endWdate = $component->_date2timestamp( $end );
900
-      if( $endWdate < $startWdate ) { // MUST be after start date!!
896
+    // if( isset($end))  echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
897
+        }
898
+        $endWdate = $component->_date2timestamp( $end );
899
+        if( $endWdate < $startWdate ) { // MUST be after start date!!
901 900
         $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
902 901
         $endWdate = $component->_date2timestamp( $end );
903
-      }
904
-      $rdurWsecs  = $endWdate - $startWdate; // compute component duration in seconds
905
-      $rdur       = $component->_date2duration( $start, $end ); // compute component duration, array
902
+        }
903
+        $rdurWsecs  = $endWdate - $startWdate; // compute component duration in seconds
904
+        $rdur       = $component->_date2duration( $start, $end ); // compute component duration, array
906 905
             /* make a list of optional exclude dates for component occurence from exrule and exdate */
907
-      $exdatelist = array();
908
-      $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
909
-      $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
910
-      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
906
+        $exdatelist = array();
907
+        $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
908
+        $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
909
+        while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
911 910
         $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
912
-      while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
911
+        while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
913 912
         foreach( $exdate as $theExdate ) {
914
-          $exWdate = $component->_date2timestamp( $theExdate );
915
-          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
913
+            $exWdate = $component->_date2timestamp( $theExdate );
914
+            if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
916 915
             $exdatelist[$exWdate] = TRUE;
917 916
         }
918
-      }
917
+        }
919 918
             /* if 'any' components, check repeating components, removing all excluding dates */
920
-      if( TRUE === $any ) {
919
+        if( TRUE === $any ) {
921 920
             /* make a list of optional repeating dates for component occurence, rrule, rdate */
922 921
         $recurlist = array();
923 922
         while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
924
-          $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
923
+            $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
925 924
         foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
926
-          $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
925
+            $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
927 926
         while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
928
-          foreach( $rdate as $theRdate ) {
927
+            foreach( $rdate as $theRdate ) {
929 928
             if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
930 929
                    array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
931
-              $rstart = $component->_date2timestamp( $theRdate[0] );
932
-              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
930
+                $rstart = $component->_date2timestamp( $theRdate[0] );
931
+                if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
933 932
                 continue;
934
-              if( isset( $theRdate[1]['year'] )) // date-date period
933
+                if( isset( $theRdate[1]['year'] )) // date-date period
935 934
                 $rend = $component->_date2timestamp( $theRdate[1] );
936
-              else {                             // date-duration period
935
+                else {                             // date-duration period
937 936
                 $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
938 937
                 $rend = $component->_date2timestamp( $rend );
939
-              }
940
-              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
938
+                }
939
+                if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
941 940
                 $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
942 941
             } // PERIOD end
943 942
             else { // single date
944
-              $theRdate = $component->_date2timestamp( $theRdate );
945
-              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
943
+                $theRdate = $component->_date2timestamp( $theRdate );
944
+                if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
946 945
                 $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
947 946
             }
948
-          }
947
+            }
949 948
         }
950 949
         if( 0 < count( $recurlist )) {
951
-          ksort( $recurlist );
952
-          foreach( $recurlist as $recurkey => $durvalue ) {
950
+            ksort( $recurlist );
951
+            foreach( $recurlist as $recurkey => $durvalue ) {
953 952
             if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
954
-              continue;
953
+                continue;
955 954
             if( isset( $exdatelist[$recurkey] )) // check excluded dates
956
-              continue;
955
+                continue;
957 956
             if( $startWdate >= $recurkey ) // exclude component start date
958
-              continue;
957
+                continue;
959 958
             $component2   = $component->copy();
960 959
             $rstart       = $component2->_timestamp2date( $recurkey, 6);
961 960
             $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
962 961
             if( isset( $start['hour'] ) || isset( $start['min'] ) || isset( $start['sec'] )) {
963
-              $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00';
964
-              $datevalue .= ( isset( $rstart['min'] ))  ? ':'.$rstart['min']  : ':00';
965
-              $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
962
+                $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00';
963
+                $datevalue .= ( isset( $rstart['min'] ))  ? ':'.$rstart['min']  : ':00';
964
+                $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
966 965
             }
967 966
             $datestring = date( $startDateFormat, strtotime( $datevalue ));
968 967
             if( isset( $start['tz'] ))
969
-              $datestring .= ' '.$start['tz'];
968
+                $datestring .= ' '.$start['tz'];
970 969
             $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
971 970
             $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
972 971
             if( $dtendExist || $dueExist ) {
973
-              if( $endAllDayEvent ) {
972
+                if( $endAllDayEvent ) {
974 973
                 $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
975 974
                 $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
976
-              }
977
-              else {
975
+                }
976
+                else {
978 977
                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
979 978
                 if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) {
980
-                  $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
981
-                  $datevalue .= ( isset( $rend['min'] ))  ? ':'.$rend['min']  : ':00';
982
-                  $datevalue .= ( isset( $rend['sec'] ))  ? ':'.$rend['sec']  : ':00';
979
+                    $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
980
+                    $datevalue .= ( isset( $rend['min'] ))  ? ':'.$rend['min']  : ':00';
981
+                    $datevalue .= ( isset( $rend['sec'] ))  ? ':'.$rend['sec']  : ':00';
982
+                }
983 983
                 }
984
-              }
985
-              $datestring = date( $endDateFormat, strtotime( $datevalue ));
986
-              if( isset( $end['tz'] ))
984
+                $datestring = date( $endDateFormat, strtotime( $datevalue ));
985
+                if( isset( $end['tz'] ))
987 986
                 $datestring .= ' '.$end['tz'];
988
-              if( $dtendExist )
987
+                if( $dtendExist )
989 988
                 $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
990
-              elseif( $dueExist )
989
+                elseif( $dueExist )
991 990
                 $component2->setProperty( 'X-CURRENT-DUE', $datestring );
992 991
             }
993 992
             $rend   = $component2->_date2timestamp( $rend );
994 993
             $rstart = $recurkey;
995 994
             /* add repeating components within valid dates to output array, only start date */
996 995
             if( $flat )
997
-              $result[] = $component2->copy(); // copy to output
996
+                $result[] = $component2->copy(); // copy to output
998 997
             elseif( $split ) {
999
-              if( $rend > $endDate )
998
+                if( $rend > $endDate )
1000 999
                 $rend = $endDate;
1001
-              while( $rstart <= $rend ) { // iterate
1000
+                while( $rstart <= $rend ) { // iterate
1002 1001
                 $wd = getdate( $rstart );
1003 1002
                 if(( $rstart > $startDate ) &&      // date after dtstart
1004 1003
                     !isset( $exdatelist[$rstart] )) // check exclude date
1005
-                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1004
+                    $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1006 1005
                 $rstart += ( 24*60*60 ); // step one day
1007
-              }
1006
+                }
1008 1007
             }
1009 1008
             elseif(( $rstart >= $startDate ) &&     // date within period
1010 1009
                   !isset( $exdatelist[$rstart] )) { // check exclude date
1011
-              $wd = getdate( $rstart );
1012
-              $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1010
+                $wd = getdate( $rstart );
1011
+                $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1012
+            }
1013 1013
             }
1014
-          }
1015 1014
         }
1016 1015
             /* deselect components with startdate/enddate not within period */
1017 1016
         if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1018
-      }
1017
+        }
1019 1018
             /* deselect components with startdate not within period */
1020
-      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1019
+        elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1021 1020
             /* add selected components within valid dates to output array */
1022
-      if( $flat )
1021
+        if( $flat )
1023 1022
         $result[] = $component->copy(); // copy to output;
1024
-      elseif( $split ) {
1023
+        elseif( $split ) {
1025 1024
         if( $endWdate > $endDate )
1026
-          $endWdate = $endDate;     // use period end date
1025
+            $endWdate = $endDate;     // use period end date
1027 1026
         if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1028
-          if( $startWdate < $startDate )
1027
+            if( $startWdate < $startDate )
1029 1028
             $startWdate = $startDate; // use period start date
1030
-          while( $startWdate <= $endWdate ) { // iterate
1029
+            while( $startWdate <= $endWdate ) { // iterate
1031 1030
             $wd = getdate( $startWdate );
1032 1031
             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1033 1032
             $startWdate += ( 24*60*60 ); // step one day
1034
-          }
1033
+            }
1035 1034
         }
1036
-      } // use component date
1037
-      elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1035
+        } // use component date
1036
+        elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1038 1037
             ( $startWdate >= $startDate )) {          // within period
1039 1038
         $wd = getdate( $startWdate );
1040 1039
         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041
-      }
1040
+        }
1042 1041
     }
1043 1042
     if( 0 >= count( $result )) return FALSE;
1044 1043
     elseif( !$flat ) {
1045
-      foreach( $result as $y => $yeararr ) {
1044
+        foreach( $result as $y => $yeararr ) {
1046 1045
         foreach( $yeararr as $m => $montharr ) {
1047
-          ksort( $result[$y][$m] );
1046
+            ksort( $result[$y][$m] );
1048 1047
         }
1049 1048
         ksort( $result[$y] );
1050
-      }
1051
-      ksort( $result );
1049
+        }
1050
+        ksort( $result );
1052 1051
     }
1053 1052
     return $result;
1054
-  }
1053
+    }
1055 1054
 /**
1056
- * add calendar component to container
1057
- *
1058
- * @author Kjell-Inge Gustafsson <[email protected]>
1059
- * @since 2.4.10 - 2008-08-06
1060
- * @param object $component calendar component
1061
- * @param mixed $arg1 optional, ordno/component type/ component uid
1062
- * @param mixed $arg2 optional, ordno if arg1 = component type
1063
- * @return void
1064
- */
1065
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1055
+     * add calendar component to container
1056
+     *
1057
+     * @author Kjell-Inge Gustafsson <[email protected]>
1058
+     * @since 2.4.10 - 2008-08-06
1059
+     * @param object $component calendar component
1060
+     * @param mixed $arg1 optional, ordno/component type/ component uid
1061
+     * @param mixed $arg2 optional, ordno if arg1 = component type
1062
+     * @return void
1063
+     */
1064
+    function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066 1065
     if( '' >= $component->getConfig( 'language'))
1067
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
1066
+        $component->setConfig( 'language',  $this->getConfig( 'language' ));
1068 1067
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1069 1068
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1070 1069
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1071 1070
     $component->setConfig( 'format',      $this->getConfig( 'format' ));
1072 1071
     if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) {
1073
-      unset( $component->propix );
1072
+        unset( $component->propix );
1074 1073
             /* make sure dtstamp and uid is set */
1075
-      $dummy1 = $component->getProperty( 'dtstamp' );
1076
-      $dummy2 = $component->getProperty( 'uid' );
1074
+        $dummy1 = $component->getProperty( 'dtstamp' );
1075
+        $dummy2 = $component->getProperty( 'uid' );
1077 1076
     }
1078 1077
     if( !$arg1 ) {
1079
-      $this->components[] = $component->copy();
1080
-      return TRUE;
1078
+        $this->components[] = $component->copy();
1079
+        return TRUE;
1081 1080
     }
1082 1081
     $argType = $index = null;
1083 1082
     if ( ctype_digit( (string) $arg1 )) {
1084
-      $argType = 'INDEX';
1085
-      $index   = (int) $arg1 - 1;
1083
+        $argType = 'INDEX';
1084
+        $index   = (int) $arg1 - 1;
1086 1085
     }
1087 1086
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1088
-      $argType = strtolower( $arg1 );
1089
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1087
+        $argType = strtolower( $arg1 );
1088
+        $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1090 1089
     }
1091 1090
     $cix1sC = 0;
1092 1091
     foreach ( $this->components as $cix => $component2) {
1093
-      if( empty( $component2 )) continue;
1094
-      unset( $component2->propix );
1095
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1092
+        if( empty( $component2 )) continue;
1093
+        unset( $component2->propix );
1094
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1096 1095
         $this->components[$cix] = $component->copy();
1097 1096
         return TRUE;
1098
-      }
1099
-      elseif( $argType == $component2->objName ) {
1097
+        }
1098
+        elseif( $argType == $component2->objName ) {
1100 1099
         if( $index == $cix1sC ) {
1101
-          $this->components[$cix] = $component->copy();
1102
-          return TRUE;
1100
+            $this->components[$cix] = $component->copy();
1101
+            return TRUE;
1103 1102
         }
1104 1103
         $cix1sC++;
1105
-      }
1106
-      elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1104
+        }
1105
+        elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1107 1106
         $this->components[$cix] = $component->copy();
1108 1107
         return TRUE;
1109
-      }
1108
+        }
1110 1109
     }
1111 1110
             /* not found.. . insert last in chain anyway .. .*/
1112 1111
     $this->components[] = $component->copy();
1113 1112
     return TRUE;
1114
-  }
1113
+    }
1115 1114
 /**
1116
- * sort iCal compoments, only local date sort
1117
- *
1118
- * ascending sort on properties (if exist) x-current-dtstart, dtstart,
1119
- * x-current-dtend, dtend, x-current-due, due, duration, created, dtstamp, uid
1120
- *
1121
- * @author Kjell-Inge Gustafsson <[email protected]>
1122
- * @since 2.4.10 - 2008-09-24
1123
- * @return sort param
1124
- *
1125
- */
1126
-  function sort() {
1115
+     * sort iCal compoments, only local date sort
1116
+     *
1117
+     * ascending sort on properties (if exist) x-current-dtstart, dtstart,
1118
+     * x-current-dtend, dtend, x-current-due, due, duration, created, dtstamp, uid
1119
+     *
1120
+     * @author Kjell-Inge Gustafsson <[email protected]>
1121
+     * @since 2.4.10 - 2008-09-24
1122
+     * @return sort param
1123
+     *
1124
+     */
1125
+    function sort() {
1127 1126
     if( is_array( $this->components )) {
1128
-      $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' );
1129
-      usort( $this->components, array( $this, '_cmpfcn' ));
1127
+        $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' );
1128
+        usort( $this->components, array( $this, '_cmpfcn' ));
1130 1129
     }
1131
-  }
1132
-  function _cmpfcn( $a, $b ) {
1130
+    }
1131
+    function _cmpfcn( $a, $b ) {
1133 1132
     if( empty( $a ))                                   return -1;
1134 1133
     if( empty( $b ))                                   return  1;
1135 1134
     if(  'vtimezone' == $a->objName)                   return -1;
1136 1135
     if(  'vtimezone' == $b->objName)                   return  1;
1137 1136
     $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1138 1137
     if( empty( $astart ) && isset( $a->dtstart['value'] ))
1139
-      $astart = & $a->dtstart['value'];
1138
+        $astart = & $a->dtstart['value'];
1140 1139
     $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1141 1140
     if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1142
-      $bstart = & $b->dtstart['value'];
1141
+        $bstart = & $b->dtstart['value'];
1143 1142
     if(     empty( $astart ))                          return -1;
1144 1143
     elseif( empty( $bstart ))                          return  1;
1145 1144
     foreach( $this->_sortkeys as $key ) {
1146
-      if    ( empty( $astart[$key] ))                  return -1;
1147
-      elseif( empty( $bstart[$key] ))                  return  1;
1148
-      if    (        $astart[$key] == $bstart[$key])   continue;
1149
-      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1150
-                                                       return -1;
1151
-      elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1152
-                                                       return  1;
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] ))
1149
+                                                        return -1;
1150
+        elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1151
+                                                        return  1;
1153 1152
     }
1154 1153
     $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1155 1154
     if(     empty( $c ) && !empty( $a->dtend['value'] ))
1156
-      $c = & $a->dtend['value'];
1155
+        $c = & $a->dtend['value'];
1157 1156
     if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1158
-      $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1157
+        $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1159 1158
     if(     empty( $c ) && !empty( $a->due['value'] ))
1160
-      $c = & $a->due['value'];
1159
+        $c = & $a->due['value'];
1161 1160
     if(     empty( $c ) && !empty( $a->duration['value'] ))
1162
-      $c = $a->duration2date();
1161
+        $c = $a->duration2date();
1163 1162
     $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1164 1163
     if(     empty( $d ) && !empty( $b->dtend['value'] ))
1165
-      $d = & $b->dtend['value'];
1164
+        $d = & $b->dtend['value'];
1166 1165
     if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1167
-      $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1166
+        $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1168 1167
     if(     empty( $d ) && !empty( $b->due['value'] ))
1169
-      $d = & $b->due['value'];
1168
+        $d = & $b->due['value'];
1170 1169
     if(     empty( $d ) && !empty( $b->duration['value'] ))
1171
-      $d = $b->duration2date();
1170
+        $d = $b->duration2date();
1172 1171
     if(     empty( $c ))                               return -1;
1173 1172
     elseif( empty( $d ))                               return  1;
1174 1173
     foreach( $this->_sortkeys as $key ) {
1175
-      if    ( !isset( $c[$key] ))                      return -1;
1176
-      elseif( !isset( $d[$key] ))                      return  1;
1177
-      if    (         $c[$key] == $d[$key] )           continue;
1178
-      if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1179
-      elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
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;
1180 1179
     }
1181 1180
     if( isset( $a->created['value'] ))
1182
-     $e = & $a->created['value'];
1181
+        $e = & $a->created['value'];
1183 1182
     else
1184
-     $e = & $a->dtstamp['value'];
1183
+        $e = & $a->dtstamp['value'];
1185 1184
     if( isset( $b->created['value'] ))
1186
-      $f = & $b->created['value'];
1185
+        $f = & $b->created['value'];
1187 1186
     else
1188
-      $f = & $b->dtstamp['value'];
1187
+        $f = & $b->dtstamp['value'];
1189 1188
     foreach( $this->_sortkeys as $key ) {
1190
-      if(       !isset( $e[$key] ))                    return -1;
1191
-      elseif(   !isset( $f[$key] ))                    return  1;
1192
-      if    (           $e[$key] == $f[$key] )         continue;
1193
-      if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1194
-      elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
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;
1195 1194
     }
1196 1195
     if    ((            $a->uid['value'] ) <
1197
-           (            $b->uid['value'] ))            return -1;
1196
+            (            $b->uid['value'] ))            return -1;
1198 1197
     elseif((            $a->uid['value'] ) >
1199
-           (            $b->uid['value'] ))            return  1;
1198
+            (            $b->uid['value'] ))            return  1;
1200 1199
     return 0;
1201
-  }
1200
+    }
1202 1201
 /**
1203
- * parse iCal file into vcalendar, components, properties and parameters
1204
- *
1205
- * @author Kjell-Inge Gustafsson <[email protected]>
1206
- * @since 2.4.10 - 2008-08-06
1207
- * @param string $filename optional filname (incl. opt. directory/path) or URL
1208
- * @return bool FALSE if error occurs during parsing
1209
- *
1210
- */
1211
-  function parse( $filename=FALSE ) {
1202
+     * parse iCal file into vcalendar, components, properties and parameters
1203
+     *
1204
+     * @author Kjell-Inge Gustafsson <[email protected]>
1205
+     * @since 2.4.10 - 2008-08-06
1206
+     * @param string $filename optional filname (incl. opt. directory/path) or URL
1207
+     * @return bool FALSE if error occurs during parsing
1208
+     *
1209
+     */
1210
+    function parse( $filename=FALSE ) {
1212 1211
     if( !$filename ) {
1213 1212
             /* directory/filename previous set via setConfig directory+filename / url */
1214
-      if( FALSE === ( $filename = $this->getConfig( 'url' )))
1213
+        if( FALSE === ( $filename = $this->getConfig( 'url' )))
1215 1214
         $filename = $this->getConfig( 'dirfile' );
1216 1215
     }
1217 1216
     elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1218 1217
            ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1219 1218
             /* remote file - URL */
1220
-      $this->setConfig( 'URL', $filename );
1221
-      if( !$filename = $this->getConfig( 'url' ))
1219
+        $this->setConfig( 'URL', $filename );
1220
+        if( !$filename = $this->getConfig( 'url' ))
1222 1221
         return FALSE;                 /* err 2 */
1223 1222
     }
1224 1223
     else {
1225 1224
             /* local directory/filename */
1226
-      $parts = pathinfo( $filename );
1227
-      if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1225
+        $parts = pathinfo( $filename );
1226
+        if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1228 1227
         if( !$this->setConfig( 'directory', $parts['dirname'] ))
1229
-          return FALSE;               /* err 3 */
1230
-      }
1231
-      if( !$this->setConfig( 'filename', $parts['basename'] ))
1228
+            return FALSE;               /* err 3 */
1229
+        }
1230
+        if( !$this->setConfig( 'filename', $parts['basename'] ))
1232 1231
         return FALSE;                 /* err 4 */
1233 1232
     }
1234 1233
     if( 'http://' != substr( $filename, 0, 7 )) {
1235 1234
             /* local file error tests */
1236
-      if( !is_file( $filename ))      /* err 5 */
1235
+        if( !is_file( $filename ))      /* err 5 */
1237 1236
         return FALSE;
1238
-      if( !is_readable( $filename ))
1237
+        if( !is_readable( $filename ))
1239 1238
         return FALSE;                 /* err 6 */
1240
-      if( !filesize( $filename ))
1239
+        if( !filesize( $filename ))
1241 1240
         return FALSE;                 /* err 7 */
1242
-      clearstatcache();
1241
+        clearstatcache();
1243 1242
     }
1244 1243
             /* READ FILE */
1245 1244
     if( FALSE === ( $rows = file( $filename )))
1246
-      return FALSE;                   /* err 1 */
1245
+        return FALSE;                   /* err 1 */
1247 1246
             /* identify BEGIN:VCALENDAR, MUST be first row */
1248 1247
     if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1249
-      return FALSE;                   /* err 8 */
1248
+        return FALSE;                   /* err 8 */
1250 1249
             /* remove empty trailing lines */
1251 1250
     while( '' == trim( $rows[count( $rows ) - 1] )) {
1252
-      unset( $rows[count( $rows ) - 1] );
1253
-      $rows  = array_values( $rows );
1251
+        unset( $rows[count( $rows ) - 1] );
1252
+        $rows  = array_values( $rows );
1254 1253
     }
1255 1254
             /* identify ending END:VCALENDAR row */
1256 1255
     if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1257
-      return FALSE;                   /* err 9 */
1256
+        return FALSE;                   /* err 9 */
1258 1257
     }
1259 1258
     if( 3 > count( $rows ))
1260
-      return FALSE;                   /* err 10 */
1259
+        return FALSE;                   /* err 10 */
1261 1260
     $comp    = $subcomp = null;
1262 1261
     $actcomp = & $this;
1263 1262
     $nl      = $this->getConfig( 'nl' );
1264 1263
     $calsync = 0;
1265 1264
             /* identify components and update unparsed data within component */
1266 1265
     foreach( $rows as $line ) {
1267
-      if( '' == trim( $line ))
1266
+        if( '' == trim( $line ))
1268 1267
         continue;
1269
-      if( $nl == substr( $line, 0 - strlen( $nl )))
1268
+        if( $nl == substr( $line, 0 - strlen( $nl )))
1270 1269
         $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1271
-      if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1270
+        if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1272 1271
         $calsync++;
1273 1272
         continue;
1274
-      }
1275
-      elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1273
+        }
1274
+        elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1276 1275
         $calsync--;
1277 1276
         continue;
1278
-      }
1279
-      elseif( 1 != $calsync )
1277
+        }
1278
+        elseif( 1 != $calsync )
1280 1279
         return FALSE;                 /* err 20 */
1281
-      if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1280
+        if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1282 1281
         if( null != $subcomp ) {
1283
-          $comp->setComponent( $subcomp );
1284
-          $subcomp = null;
1282
+            $comp->setComponent( $subcomp );
1283
+            $subcomp = null;
1285 1284
         }
1286 1285
         else {
1287
-          $this->setComponent( $comp );
1288
-          $comp = null;
1286
+            $this->setComponent( $comp );
1287
+            $comp = null;
1289 1288
         }
1290 1289
         $actcomp = null;
1291 1290
         continue;
1292
-      } // end - if ( 'END:' ==.. .
1293
-      elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) {
1291
+        } // end - if ( 'END:' ==.. .
1292
+        elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) {
1294 1293
         $line = str_replace( '\n', '', $line );
1295 1294
         $compname = trim (strtoupper( substr( $line, 6 )));
1296 1295
         if( null != $comp ) {
1297
-          if( 'VALARM' == $compname )
1296
+            if( 'VALARM' == $compname )
1298 1297
             $subcomp = new valarm();
1299
-          elseif( 'STANDARD' == $compname )
1298
+            elseif( 'STANDARD' == $compname )
1300 1299
             $subcomp = new vtimezone( 'STANDARD' );
1301
-          elseif( 'DAYLIGHT' == $compname )
1300
+            elseif( 'DAYLIGHT' == $compname )
1302 1301
             $subcomp = new vtimezone( 'DAYLIGHT' );
1303
-          else
1302
+            else
1304 1303
             return FALSE; /* err 6 */
1305
-          $actcomp = & $subcomp;
1304
+            $actcomp = & $subcomp;
1306 1305
         }
1307 1306
         else {
1308
-          switch( $compname ) {
1307
+            switch( $compname ) {
1309 1308
             case 'VALARM':
1310 1309
               $comp = new valarm();
1311
-              break;
1310
+                break;
1312 1311
             case 'VEVENT':
1313 1312
               $comp = new vevent();
1314
-              break;
1313
+                break;
1315 1314
             case 'VFREEBUSY';
1316
-              $comp = new vfreebusy();
1317
-              break;
1315
+                $comp = new vfreebusy();
1316
+                break;
1318 1317
             case 'VJOURNAL':
1319 1318
               $comp = new vjournal();
1320
-              break;
1319
+                break;
1321 1320
             case 'VTODO':
1322 1321
               $comp = new vtodo();
1323
-              break;
1322
+                break;
1324 1323
             case 'VTIMEZONE':
1325 1324
               $comp = new vtimezone();
1326
-              break;
1325
+                break;
1327 1326
             default:
1328 1327
               return FALSE; // err 7
1329
-              break;
1330
-          } // end - switch
1331
-          $actcomp = & $comp;
1328
+                break;
1329
+            } // end - switch
1330
+            $actcomp = & $comp;
1332 1331
         }
1333 1332
         continue;
1334
-      } // end - elsif ( 'BEGIN:'.. .
1333
+        } // end - elsif ( 'BEGIN:'.. .
1335 1334
             /* update selected component with unparsed data */
1336
-      $actcomp->unparsed[] = $line;
1335
+        $actcomp->unparsed[] = $line;
1337 1336
     } // end - foreach( rows.. .
1338 1337
             /* parse data for calendar (this) object */
1339 1338
     if( is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) {
1340 1339
             /* concatenate property values spread over several lines */
1341
-      $lastix    = -1;
1342
-      $propnames = array( 'calscale','method','prodid','version','x-' );
1343
-      $proprows  = array();
1344
-      foreach( $this->unparsed as $line ) {
1340
+        $lastix    = -1;
1341
+        $propnames = array( 'calscale','method','prodid','version','x-' );
1342
+        $proprows  = array();
1343
+        foreach( $this->unparsed as $line ) {
1345 1344
         $newProp = FALSE;
1346 1345
         foreach ( $propnames as $propname ) {
1347
-          if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
1346
+            if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
1348 1347
             $newProp = TRUE;
1349 1348
             break;
1350
-          }
1349
+            }
1351 1350
         }
1352 1351
         if( $newProp ) {
1353
-          $newProp = FALSE;
1354
-          $lastix++;
1355
-          $proprows[$lastix]  = $line;
1352
+            $newProp = FALSE;
1353
+            $lastix++;
1354
+            $proprows[$lastix]  = $line;
1356 1355
         }
1357 1356
         else {
1358 1357
             /* remove line breaks */
1359
-          if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1358
+            if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1360 1359
              (  ' ' == substr( $line, 0, 1 ))) {
1361 1360
             $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
1362 1361
             $line = substr( $line, 1 );
1363
-          }
1364
-          $proprows[$lastix] .= $line;
1362
+            }
1363
+            $proprows[$lastix] .= $line;
1364
+        }
1365 1365
         }
1366
-      }
1367
-      $toolbox = new calendarComponent();
1368
-      foreach( $proprows as $line ) {
1366
+        $toolbox = new calendarComponent();
1367
+        foreach( $proprows as $line ) {
1369 1368
         if( '\n' == substr( $line, -2 ))
1370
-          $line = substr( $line, 0, strlen( $line ) - 2 );
1369
+            $line = substr( $line, 0, strlen( $line ) - 2 );
1371 1370
             /* get propname */
1372 1371
         $cix = $propname = null;
1373 1372
         for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1374
-          if( in_array( $line{$cix}, array( ':', ';' )))
1373
+            if( in_array( $line{$cix}, array( ':', ';' )))
1375 1374
             break;
1376
-          else
1375
+            else
1377 1376
             $propname .= $line{$cix};
1378 1377
         }
1379 1378
             /* ignore version/prodid properties */
1380 1379
         if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1381
-          continue;
1380
+            continue;
1382 1381
         $line = substr( $line, $cix);
1383 1382
             /* separate attributes from value */
1384 1383
         $attr   = array();
1385 1384
         $attrix = -1;
1386 1385
         $strlen = strlen( $line );
1387 1386
         for( $cix=0; $cix < $strlen; $cix++ ) {
1388
-          if((       ':'   == $line{$cix} )             &&
1387
+            if((       ':'   == $line{$cix} )             &&
1389 1388
                    ( '://' != substr( $line, $cix, 3 )) &&
1390 1389
              ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
1391 1390
             $attrEnd = TRUE;
1392 1391
             if(( $cix < ( $strlen - 4 )) &&
1393 1392
                  ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
1394
-              for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
1393
+                for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
1395 1394
                 if( '://' == substr( $line, $c2ix - 2, 3 )) {
1396
-                  $attrEnd = FALSE;
1397
-                  break; // an URI with a portnr!!
1395
+                    $attrEnd = FALSE;
1396
+                    break; // an URI with a portnr!!
1397
+                }
1398 1398
                 }
1399
-              }
1400 1399
             }
1401 1400
             if( $attrEnd) {
1402
-              $line = substr( $line, $cix + 1 );
1403
-              break;
1401
+                $line = substr( $line, $cix + 1 );
1402
+                break;
1404 1403
             }
1405
-          }
1406
-          if( ';' == $line{$cix} )
1404
+            }
1405
+            if( ';' == $line{$cix} )
1407 1406
             $attr[++$attrix] = null;
1408
-          else
1407
+            else
1409 1408
             $attr[$attrix] .= $line{$cix};
1410 1409
         }
1411 1410
 
1412 1411
             /* make attributes in array format */
1413 1412
         $propattr = array();
1414 1413
         foreach( $attr as $attribute ) {
1415
-          $attrsplit = explode( '=', $attribute, 2 );
1416
-          if( 1 < count( $attrsplit ))
1414
+            $attrsplit = explode( '=', $attribute, 2 );
1415
+            if( 1 < count( $attrsplit ))
1417 1416
             $propattr[$attrsplit[0]] = $attrsplit[1];
1418
-          else
1417
+            else
1419 1418
             $propattr[] = $attribute;
1420 1419
         }
1421 1420
             /* update Property */
1422 1421
         if( FALSE !== strpos( $line, ',' )) {
1423
-          $content  = explode( ',', $line );
1424
-          $clen     = count( $content );
1425
-          for( $cix = 0; $cix < $clen; $cix++ ) {
1422
+            $content  = explode( ',', $line );
1423
+            $clen     = count( $content );
1424
+            for( $cix = 0; $cix < $clen; $cix++ ) {
1426 1425
             if( "\\" == substr( $content[$cix], -1 )) {
1427
-              $content[$cix] .= ','.$content[$cix + 1];
1428
-              unset( $content[$cix + 1] );
1429
-              $cix++;
1426
+                $content[$cix] .= ','.$content[$cix + 1];
1427
+                unset( $content[$cix + 1] );
1428
+                $cix++;
1430 1429
             }
1431
-          }
1432
-          if( 1 < count( $content )) {
1430
+            }
1431
+            if( 1 < count( $content )) {
1433 1432
             foreach( $content as $cix => $contentPart )
1434
-              $content[$cix] = $toolbox->_strunrep( $contentPart );
1433
+                $content[$cix] = $toolbox->_strunrep( $contentPart );
1435 1434
             $this->setProperty( $propname, $content, $propattr );
1436 1435
             continue;
1437
-          }
1438
-          else
1436
+            }
1437
+            else
1439 1438
             $line = reset( $content );
1440
-          $line = $toolbox->_strunrep( $line );
1439
+            $line = $toolbox->_strunrep( $line );
1441 1440
         }
1442 1441
         $this->setProperty( $propname, trim( $line ), $propattr );
1443
-      } // end - foreach( $this->unparsed.. .
1442
+        } // end - foreach( $this->unparsed.. .
1444 1443
     } // end - if( is_array( $this->unparsed.. .
1445 1444
             /* parse Components */
1446 1445
     if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1447
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
1446
+        for( $six = 0; $six < count( $this->components ); $six++ ) {
1448 1447
         if( !empty( $this->components[$six] ))
1449
-          $this->components[$six]->parse();
1450
-      }
1448
+            $this->components[$six]->parse();
1449
+        }
1451 1450
     }
1452 1451
     else
1453
-      return FALSE;                   /* err 91 or something.. . */
1452
+        return FALSE;                   /* err 91 or something.. . */
1454 1453
     return TRUE;
1455
-  }
1454
+    }
1456 1455
 /*********************************************************************************/
1457 1456
 /**
1458 1457
  * creates formatted output for calendar object instance
@@ -1461,17 +1460,17 @@  discard block
 block discarded – undo
1461 1460
  * @since 2.4.10 - 2008-08-06
1462 1461
  * @return string
1463 1462
  */
1464
-  function createCalendar() {
1463
+    function createCalendar() {
1465 1464
     $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null;
1466 1465
     switch( $this->format ) {
1467
-      case 'xcal':
1466
+        case 'xcal':
1468 1467
         $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl.
1469
-                         '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
1470
-                         '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"';
1468
+                            '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
1469
+                            '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"';
1471 1470
         $calendarInit2 = '>'.$this->nl;
1472 1471
         $calendarStart = '<vcalendar';
1473 1472
         break;
1474
-      default:
1473
+        default:
1475 1474
         $calendarStart = 'BEGIN:VCALENDAR'.$this->nl;
1476 1475
         break;
1477 1476
     }
@@ -1480,175 +1479,175 @@  discard block
 block discarded – undo
1480 1479
     $calendarStart .= $this->createProdid();
1481 1480
     $calendarStart .= $this->createVersion();
1482 1481
     switch( $this->format ) {
1483
-      case 'xcal':
1482
+        case 'xcal':
1484 1483
         $nlstrlen = strlen( $this->nl );
1485 1484
         if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1486
-          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1485
+            $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1487 1486
         $calendarStart .= '>'.$this->nl;
1488 1487
         break;
1489
-      default:
1488
+        default:
1490 1489
         break;
1491 1490
     }
1492 1491
     $calendar .= $this->createXprop();
1493 1492
     foreach( $this->components as $component ) {
1494
-      if( empty( $component )) continue;
1495
-      if( '' >= $component->getConfig( 'language'))
1493
+        if( empty( $component )) continue;
1494
+        if( '' >= $component->getConfig( 'language'))
1496 1495
         $component->setConfig( 'language',  $this->getConfig( 'language' ));
1497
-      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1498
-      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1499
-      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1500
-      $component->setConfig( 'format',      $this->getConfig( 'format' ));
1501
-      $calendar .= $component->createComponent( $this->xcaldecl );
1496
+        $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1497
+        $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1498
+        $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1499
+        $component->setConfig( 'format',      $this->getConfig( 'format' ));
1500
+        $calendar .= $component->createComponent( $this->xcaldecl );
1502 1501
     }
1503 1502
     if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only
1504
-      $calendarInit1 .= $this->nl.'['.$this->nl;
1505
-      $old_xcaldecl = array();
1506
-      foreach( $this->xcaldecl as $declix => $declPart ) {
1503
+        $calendarInit1 .= $this->nl.'['.$this->nl;
1504
+        $old_xcaldecl = array();
1505
+        foreach( $this->xcaldecl as $declix => $declPart ) {
1507 1506
         if(( 0 < count( $old_xcaldecl)) &&
1508 1507
            ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1509 1508
            ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1510
-          continue; // no duplicate uri and ext. references
1509
+            continue; // no duplicate uri and ext. references
1511 1510
         $calendarxCaldecl .= '<!';
1512 1511
         foreach( $declPart as $declKey => $declValue ) {
1513
-          switch( $declKey ) {                    // index
1512
+            switch( $declKey ) {                    // index
1514 1513
             case 'xmldecl':                       // no 1
1515 1514
               $calendarxCaldecl .= $declValue.' ';
1516
-              break;
1515
+                break;
1517 1516
             case 'uri':                           // no 2
1518 1517
               $calendarxCaldecl .= $declValue.' ';
1519
-              $old_xcaldecl['uri'][] = $declValue;
1520
-              break;
1518
+                $old_xcaldecl['uri'][] = $declValue;
1519
+                break;
1521 1520
             case 'ref':                           // no 3
1522 1521
               $calendarxCaldecl .= $declValue.' ';
1523
-              break;
1522
+                break;
1524 1523
             case 'external':                      // no 4
1525 1524
               $calendarxCaldecl .= '"'.$declValue.'" ';
1526
-              $old_xcaldecl['external'][] = $declValue;
1527
-              break;
1525
+                $old_xcaldecl['external'][] = $declValue;
1526
+                break;
1528 1527
             case 'type':                          // no 5
1529 1528
               $calendarxCaldecl .= $declValue.' ';
1530
-              break;
1529
+                break;
1531 1530
             case 'type2':                         // no 6
1532 1531
               $calendarxCaldecl .= $declValue;
1533
-              break;
1534
-          }
1532
+                break;
1533
+            }
1535 1534
         }
1536 1535
         $calendarxCaldecl .= '>'.$this->nl;
1537
-      }
1538
-      $calendarInit2 = ']'.$calendarInit2;
1536
+        }
1537
+        $calendarInit2 = ']'.$calendarInit2;
1539 1538
     }
1540 1539
     switch( $this->format ) {
1541
-      case 'xcal':
1540
+        case 'xcal':
1542 1541
         $calendar .= '</vcalendar>'.$this->nl;
1543 1542
         break;
1544
-      default:
1543
+        default:
1545 1544
         $calendar .= 'END:VCALENDAR'.$this->nl;
1546 1545
         break;
1547 1546
     }
1548 1547
     return $calendarInit1.$calendarxCaldecl.$calendarInit2.$calendarStart.$calendar;
1549
-  }
1548
+    }
1550 1549
 /**
1551
- * a HTTP redirect header is sent with created, updated and/or parsed calendar
1552
- *
1553
- * @author Kjell-Inge Gustafsson <[email protected]>
1554
- * @since 2.2.12 - 2007-10-23
1555
- * @return redirect
1556
- */
1557
-  function returnCalendar() {
1550
+     * a HTTP redirect header is sent with created, updated and/or parsed calendar
1551
+     *
1552
+     * @author Kjell-Inge Gustafsson <[email protected]>
1553
+     * @since 2.2.12 - 2007-10-23
1554
+     * @return redirect
1555
+     */
1556
+    function returnCalendar() {
1558 1557
     $filename = $this->getConfig( 'filename' );
1559 1558
     $output   = $this->createCalendar();
1560 1559
     $filesize = strlen( $output );
1561 1560
 //    if( headers_sent( $filename, $linenum ))
1562 1561
 //      die( "Headers already sent in $filename on line $linenum\n" );
1563 1562
     if( 'xcal' == $this->format )
1564
-      header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1563
+        header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1565 1564
     else
1566
-      header( 'Content-Type: text/calendar; charset=utf-8' );
1565
+        header( 'Content-Type: text/calendar; charset=utf-8' );
1567 1566
     header( 'Content-Length: '.$filesize );
1568 1567
     header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1569 1568
     header( 'Cache-Control: max-age=10' );
1570 1569
     echo $output;
1571 1570
     die();
1572
-  }
1571
+    }
1573 1572
 /**
1574
- * save content in a file
1575
- *
1576
- * @author Kjell-Inge Gustafsson <[email protected]>
1577
- * @since 2.2.12 - 2007-12-30
1578
- * @param string $directory optional
1579
- * @param string $filename optional
1580
- * @param string $delimiter optional
1581
- * @return bool
1582
- */
1583
-  function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1573
+     * save content in a file
1574
+     *
1575
+     * @author Kjell-Inge Gustafsson <[email protected]>
1576
+     * @since 2.2.12 - 2007-12-30
1577
+     * @param string $directory optional
1578
+     * @param string $filename optional
1579
+     * @param string $delimiter optional
1580
+     * @return bool
1581
+     */
1582
+    function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1584 1583
     if( $directory )
1585
-      $this->setConfig( 'directory', $directory );
1584
+        $this->setConfig( 'directory', $directory );
1586 1585
     if( $filename )
1587
-      $this->setConfig( 'filename',  $filename );
1586
+        $this->setConfig( 'filename',  $filename );
1588 1587
     if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1589
-      $this->setConfig( 'delimiter', $delimiter );
1588
+        $this->setConfig( 'delimiter', $delimiter );
1590 1589
     if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1591
-      $dirfile = $this->getConfig( 'dirfile' );
1590
+        $dirfile = $this->getConfig( 'dirfile' );
1592 1591
     $iCalFile = @fopen( $dirfile, 'w' );
1593 1592
     if( $iCalFile ) {
1594
-      if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1593
+        if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1595 1594
         return FALSE;
1596
-      fclose( $iCalFile );
1597
-      return TRUE;
1595
+        fclose( $iCalFile );
1596
+        return TRUE;
1598 1597
     }
1599 1598
     else
1600
-      return FALSE;
1601
-  }
1599
+        return FALSE;
1600
+    }
1602 1601
 /**
1603
- * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
1604
- * else FALSE is returned
1605
- *
1606
- * @author Kjell-Inge Gustafsson <[email protected]>
1607
- * @since 2.2.12 - 2007-10-28
1608
- * @param string $directory optional alt. int timeout
1609
- * @param string $filename optional
1610
- * @param string $delimiter optional
1611
- * @param int timeout optional, default 3600 sec
1612
- * @return redirect/FALSE
1613
- */
1614
-  function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) {
1602
+     * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
1603
+     * else FALSE is returned
1604
+     *
1605
+     * @author Kjell-Inge Gustafsson <[email protected]>
1606
+     * @since 2.2.12 - 2007-10-28
1607
+     * @param string $directory optional alt. int timeout
1608
+     * @param string $filename optional
1609
+     * @param string $delimiter optional
1610
+     * @param int timeout optional, default 3600 sec
1611
+     * @return redirect/FALSE
1612
+     */
1613
+    function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) {
1615 1614
     if ( $directory && ctype_digit( (string) $directory ) && !$filename ) {
1616
-      $timeout   = (int) $directory;
1617
-      $directory = FALSE;
1615
+        $timeout   = (int) $directory;
1616
+        $directory = FALSE;
1618 1617
     }
1619 1618
     if( $directory )
1620
-      $this->setConfig( 'directory', $directory );
1619
+        $this->setConfig( 'directory', $directory );
1621 1620
     if( $filename )
1622
-      $this->setConfig( 'filename',  $filename );
1621
+        $this->setConfig( 'filename',  $filename );
1623 1622
     if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1624
-      $this->setConfig( 'delimiter', $delimiter );
1623
+        $this->setConfig( 'delimiter', $delimiter );
1625 1624
     $filesize    = $this->getConfig( 'filesize' );
1626 1625
     if( 0 >= $filesize )
1627
-      return FALSE;
1626
+        return FALSE;
1628 1627
     $dirfile     = $this->getConfig( 'dirfile' );
1629 1628
     if( time() - filemtime( $dirfile ) < $timeout) {
1630
-      clearstatcache();
1631
-      $dirfile   = $this->getConfig( 'dirfile' );
1632
-      $filename  = $this->getConfig( 'filename' );
1629
+        clearstatcache();
1630
+        $dirfile   = $this->getConfig( 'dirfile' );
1631
+        $filename  = $this->getConfig( 'filename' );
1633 1632
 //    if( headers_sent( $filename, $linenum ))
1634 1633
 //      die( "Headers already sent in $filename on line $linenum\n" );
1635
-      if( 'xcal' == $this->format )
1634
+        if( 'xcal' == $this->format )
1636 1635
         header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1637
-      else
1636
+        else
1638 1637
         header( 'Content-Type: text/calendar; charset=utf-8' );
1639
-      header( 'Content-Length: '.$filesize );
1640
-      header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1641
-      header( 'Cache-Control: max-age=10' );
1642
-      $fp = @$fopen( $dirfile, 'r' );
1643
-      if( $fp ) {
1638
+        header( 'Content-Length: '.$filesize );
1639
+        header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1640
+        header( 'Cache-Control: max-age=10' );
1641
+        $fp = @$fopen( $dirfile, 'r' );
1642
+        if( $fp ) {
1644 1643
         fpassthru( $fp );
1645 1644
         fclose( $fp );
1646
-      }
1647
-      die();
1645
+        }
1646
+        die();
1648 1647
     }
1649 1648
     else
1650
-      return FALSE;
1651
-  }
1649
+        return FALSE;
1650
+    }
1652 1651
 }
1653 1652
 /*********************************************************************************/
1654 1653
 /*********************************************************************************/
@@ -1660,37 +1659,37 @@  discard block
 block discarded – undo
1660 1659
  */
1661 1660
 class calendarComponent {
1662 1661
             //  component property variables
1663
-  var $uid;
1664
-  var $dtstamp;
1662
+    var $uid;
1663
+    var $dtstamp;
1665 1664
 
1666 1665
             //  component config variables
1667
-  var $allowEmpty;
1668
-  var $language;
1669
-  var $nl;
1670
-  var $unique_id;
1671
-  var $format;
1672
-  var $objName; // created automatically at instance creation
1666
+    var $allowEmpty;
1667
+    var $language;
1668
+    var $nl;
1669
+    var $unique_id;
1670
+    var $format;
1671
+    var $objName; // created automatically at instance creation
1673 1672
             //  component internal variables
1674
-  var $componentStart1;
1675
-  var $componentStart2;
1676
-  var $componentEnd1;
1677
-  var $componentEnd2;
1678
-  var $elementStart1;
1679
-  var $elementStart2;
1680
-  var $elementEnd1;
1681
-  var $elementEnd2;
1682
-  var $intAttrDelimiter;
1683
-  var $attributeDelimiter;
1684
-  var $valueInit;
1673
+    var $componentStart1;
1674
+    var $componentStart2;
1675
+    var $componentEnd1;
1676
+    var $componentEnd2;
1677
+    var $elementStart1;
1678
+    var $elementStart2;
1679
+    var $elementEnd1;
1680
+    var $elementEnd2;
1681
+    var $intAttrDelimiter;
1682
+    var $attributeDelimiter;
1683
+    var $valueInit;
1685 1684
             //  component xCal declaration container
1686
-  var $xcaldecl;
1687
-/**
1688
- * constructor for calendar component object
1689
- *
1690
- * @author Kjell-Inge Gustafsson <[email protected]>
1691
- * @since 2.4.19 - 2008-10-23
1692
- */
1693
-  function calendarComponent() {
1685
+    var $xcaldecl;
1686
+/**
1687
+     * constructor for calendar component object
1688
+     *
1689
+     * @author Kjell-Inge Gustafsson <[email protected]>
1690
+     * @since 2.4.19 - 2008-10-23
1691
+     */
1692
+    function calendarComponent() {
1694 1693
     $this->objName         = ( isset( $this->timezonetype )) ?
1695 1694
                           strtolower( $this->timezonetype )  :  get_class ( $this );
1696 1695
     $this->uid             = array();
@@ -1705,7 +1704,7 @@  discard block
 block discarded – undo
1705 1704
 
1706 1705
     $this->_createFormat();
1707 1706
     $this->_makeDtstamp();
1708
-  }
1707
+    }
1709 1708
 /*********************************************************************************/
1710 1709
 /**
1711 1710
  * Property Name: ACTION
@@ -1717,27 +1716,27 @@  discard block
 block discarded – undo
1717 1716
  * @since 2.4.8 - 2008-10-22
1718 1717
  * @return string
1719 1718
  */
1720
-  function createAction() {
1719
+    function createAction() {
1721 1720
     if( empty( $this->action )) return FALSE;
1722 1721
     if( empty( $this->action['value'] ))
1723
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1722
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1724 1723
     $attributes = $this->_createParams( $this->action['params'] );
1725 1724
     return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1726
-  }
1725
+    }
1727 1726
 /**
1728
- * set calendar component property action
1729
- *
1730
- * @author Kjell-Inge Gustafsson <[email protected]>
1731
- * @since 2.4.8 - 2008-11-04
1732
- * @param string $value  "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
1733
- * @param mixed $params
1734
- * @return bool
1735
- */
1736
-  function setAction( $value, $params=FALSE ) {
1727
+     * set calendar component property action
1728
+     *
1729
+     * @author Kjell-Inge Gustafsson <[email protected]>
1730
+     * @since 2.4.8 - 2008-11-04
1731
+     * @param string $value  "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
1732
+     * @param mixed $params
1733
+     * @return bool
1734
+     */
1735
+    function setAction( $value, $params=FALSE ) {
1737 1736
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1738 1737
     $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1739 1738
     return TRUE;
1740
-  }
1739
+    }
1741 1740
 /*********************************************************************************/
1742 1741
 /**
1743 1742
  * Property Name: ATTACH
@@ -1749,33 +1748,33 @@  discard block
 block discarded – undo
1749 1748
  * @since 0.9.7 - 2006-11-23
1750 1749
  * @return string
1751 1750
  */
1752
-  function createAttach() {
1751
+    function createAttach() {
1753 1752
     if( empty( $this->attach )) return FALSE;
1754 1753
     $output       = null;
1755 1754
     foreach( $this->attach as $attachPart ) {
1756
-      if(! empty( $attachPart['value'] )) {
1755
+        if(! empty( $attachPart['value'] )) {
1757 1756
         $attributes = $this->_createParams( $attachPart['params'] );
1758 1757
         $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1759
-      }
1760
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1758
+        }
1759
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1761 1760
     }
1762 1761
     return $output;
1763
-  }
1762
+    }
1764 1763
 /**
1765
- * set calendar component property attach
1766
- *
1767
- * @author Kjell-Inge Gustafsson <[email protected]>
1768
- * @since 2.5.1 - 2008-11-06
1769
- * @param string $value
1770
- * @param array $params, optional
1771
- * @param integer $index, optional
1772
- * @return bool
1773
- */
1774
-  function setAttach( $value, $params=FALSE, $index=FALSE ) {
1764
+     * set calendar component property attach
1765
+     *
1766
+     * @author Kjell-Inge Gustafsson <[email protected]>
1767
+     * @since 2.5.1 - 2008-11-06
1768
+     * @param string $value
1769
+     * @param array $params, optional
1770
+     * @param integer $index, optional
1771
+     * @return bool
1772
+     */
1773
+    function setAttach( $value, $params=FALSE, $index=FALSE ) {
1775 1774
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1776 1775
     $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1777 1776
     return TRUE;
1778
-  }
1777
+    }
1779 1778
 /*********************************************************************************/
1780 1779
 /**
1781 1780
  * Property Name: ATTENDEE
@@ -1787,121 +1786,121 @@  discard block
 block discarded – undo
1787 1786
  * @since 2.4.8 - 2008-09-23
1788 1787
  * @return string
1789 1788
  */
1790
-  function createAttendee() {
1789
+    function createAttendee() {
1791 1790
     if( empty( $this->attendee )) return FALSE;
1792 1791
     $output = null;
1793 1792
     foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1794
-      if( empty( $attendeePart['value'] )) {
1793
+        if( empty( $attendeePart['value'] )) {
1795 1794
         if( $this->getConfig( 'allowEmpty' ))
1796
-          $output .= $this->_createElement( 'ATTENDEE' );
1795
+            $output .= $this->_createElement( 'ATTENDEE' );
1797 1796
         continue;
1798
-      }
1799
-      $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1800
-      foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1797
+        }
1798
+        $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1799
+        foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1801 1800
         if( 'value' == $paramlabel )
1802
-          $attendee2  .= 'MAILTO:'.$paramvalue;
1801
+            $attendee2  .= 'MAILTO:'.$paramvalue;
1803 1802
         elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1804
-          foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1803
+            foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1805 1804
             $attendee11 = $attendee12 = null;
1806 1805
             if( is_int( $optparamlabel )) {
1807
-              $attendee1 .= $this->intAttrDelimiter.$optparamvalue;
1808
-              continue;
1806
+                $attendee1 .= $this->intAttrDelimiter.$optparamvalue;
1807
+                continue;
1809 1808
             }
1810 1809
             switch( $optparamlabel ) {                                 // start switch
1811
-              case 'CUTYPE':
1810
+                case 'CUTYPE':
1812 1811
               case 'PARTSTAT':
1813 1812
               case 'ROLE':
1814 1813
               case 'RSVP':
1815 1814
                 $attendee1 .= $this->intAttrDelimiter.$optparamlabel.'="'.$optparamvalue.'"';
1816 1815
                 break;
1817
-              case 'SENT-BY':
1816
+                case 'SENT-BY':
1818 1817
                 $attendee1 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$optparamvalue.'"';
1819 1818
                 break;
1820
-              case 'MEMBER':
1819
+                case 'MEMBER':
1821 1820
                 $attendee11 = $this->intAttrDelimiter.'MEMBER=';
1822
-              case 'DELEGATED-TO':
1821
+                case 'DELEGATED-TO':
1823 1822
                 $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO='   : $attendee11;
1824
-              case 'DELEGATED-FROM':
1823
+                case 'DELEGATED-FROM':
1825 1824
                 $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11;
1826 1825
                 foreach( $optparamvalue  as $cix => $calUserAddress ) {
1827
-                  $attendee12 .= ( $cix ) ? ',' : null;
1828
-                  $attendee12 .= '"MAILTO:'.$calUserAddress.'"';
1826
+                    $attendee12 .= ( $cix ) ? ',' : null;
1827
+                    $attendee12 .= '"MAILTO:'.$calUserAddress.'"';
1829 1828
                 }
1830 1829
                 $attendee1  .= $attendee11.$attendee12;
1831 1830
                 break;
1832
-              case 'CN':
1831
+                case 'CN':
1833 1832
                 $attendeeCN .= $this->intAttrDelimiter.'CN="'.$optparamvalue.'"';
1834 1833
                 break;
1835
-              case 'DIR':
1834
+                case 'DIR':
1836 1835
                 $attendee1 .= $this->intAttrDelimiter.'DIR="'.$optparamvalue.'"';
1837 1836
                 break;
1838
-              case 'LANGUAGE':
1837
+                case 'LANGUAGE':
1839 1838
                 $attendeeLANG .= $this->intAttrDelimiter.'LANGUAGE='.$optparamvalue;
1840 1839
                 break;
1841
-              default:
1840
+                default:
1842 1841
                 $attendee1 .= $this->intAttrDelimiter."$optparamlabel=$optparamvalue";
1843 1842
                 break;
1844 1843
             }    // end switch
1845
-          }      // end foreach 3
1844
+            }      // end foreach 3
1846 1845
         }        // end elseif
1847
-      }          // end foreach 2
1848
-      $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 );
1846
+        }          // end foreach 2
1847
+        $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 );
1849 1848
     }              // end foreach 1
1850 1849
     return $output;
1851
-  }
1850
+    }
1852 1851
 /**
1853
- * set calendar component property attach
1854
- *
1855
- * @author Kjell-Inge Gustafsson <[email protected]>
1856
- * @since 2.5.1 - 2008-11-05
1857
- * @param string $value
1858
- * @param array $params, optional
1859
- * @param integer $index, optional
1860
- * @return bool
1861
- */
1862
-  function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1852
+     * set calendar component property attach
1853
+     *
1854
+     * @author Kjell-Inge Gustafsson <[email protected]>
1855
+     * @since 2.5.1 - 2008-11-05
1856
+     * @param string $value
1857
+     * @param array $params, optional
1858
+     * @param integer $index, optional
1859
+     * @return bool
1860
+     */
1861
+    function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1863 1862
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1864 1863
     $value = str_replace ( 'MAILTO:', '', $value );
1865 1864
     $value = str_replace ( 'mailto:', '', $value );
1866 1865
     $params2 = array();
1867 1866
     if( is_array($params )) {
1868
-      $optarrays = array();
1869
-      foreach( $params as $optparamlabel => $optparamvalue ) {
1867
+        $optarrays = array();
1868
+        foreach( $params as $optparamlabel => $optparamvalue ) {
1870 1869
         $optparamlabel = strtoupper( $optparamlabel );
1871 1870
         switch( $optparamlabel ) {
1872
-          case 'MEMBER':
1871
+            case 'MEMBER':
1873 1872
           case 'DELEGATED-TO':
1874 1873
           case 'DELEGATED-FROM':
1875 1874
             if( is_array( $optparamvalue )) {
1876
-              foreach( $optparamvalue as $part ) {
1875
+                foreach( $optparamvalue as $part ) {
1877 1876
                 $part = str_replace( 'MAILTO:', '', $part );
1878 1877
                 $part = str_replace( 'mailto:', '', $part );
1879 1878
                 if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1880
-                  $part = substr( $part, 1, ( strlen($part)-2 ));
1879
+                    $part = substr( $part, 1, ( strlen($part)-2 ));
1881 1880
                 $optarrays[$optparamlabel][] = $part;
1882
-              }
1881
+                }
1883 1882
             }
1884 1883
             else {
1885
-              $part = str_replace( 'MAILTO:', '', $optparamvalue );
1886
-              $part = str_replace( 'mailto:', '', $part );
1887
-              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1884
+                $part = str_replace( 'MAILTO:', '', $optparamvalue );
1885
+                $part = str_replace( 'mailto:', '', $part );
1886
+                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1888 1887
                 $part = substr( $part, 1, ( strlen($part)-2 ));
1889
-              $optarrays[$optparamlabel][] = $part;
1888
+                $optarrays[$optparamlabel][] = $part;
1890 1889
             }
1891 1890
             break;
1892
-          default:
1891
+            default:
1893 1892
             if( 'SENT-BY' ==  $optparamlabel ) {
1894
-              $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue );
1895
-              $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1893
+                $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue );
1894
+                $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1896 1895
             }
1897 1896
             if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1898 1897
                ( '"' == substr( $optparamvalue, -1 )))
1899
-              $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
1898
+                $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
1900 1899
             $params2[$optparamlabel] = $optparamvalue;
1901 1900
             break;
1902 1901
         } // end switch( $optparamlabel.. .
1903
-      } // end foreach( $optparam.. .
1904
-      foreach( $optarrays as $optparamlabel => $optparams )
1902
+        } // end foreach( $optparam.. .
1903
+        foreach( $optarrays as $optparamlabel => $optparams )
1905 1904
         $params2[$optparamlabel] = $optparams;
1906 1905
     }
1907 1906
         // remove defaults
@@ -1911,13 +1910,13 @@  discard block
 block discarded – undo
1911 1910
     $this->_existRem( $params2, 'RSVP',     'FALSE' );
1912 1911
         // check language setting
1913 1912
     if( isset( $params2['CN' ] )) {
1914
-      $lang = $this->getConfig( 'language' );
1915
-      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1913
+        $lang = $this->getConfig( 'language' );
1914
+        if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1916 1915
         $params2['LANGUAGE' ] = $lang;
1917 1916
     }
1918 1917
     $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1919 1918
     return TRUE;
1920
-  }
1919
+    }
1921 1920
 /*********************************************************************************/
1922 1921
 /**
1923 1922
  * Property Name: CATEGORIES
@@ -1929,42 +1928,42 @@  discard block
 block discarded – undo
1929 1928
  * @since 2.4.8 - 2008-10-22
1930 1929
  * @return string
1931 1930
  */
1932
-  function createCategories() {
1931
+    function createCategories() {
1933 1932
     if( empty( $this->categories )) return FALSE;
1934 1933
     $output = null;
1935 1934
     foreach( $this->categories as $category ) {
1936
-      if( empty( $category['value'] )) {
1935
+        if( empty( $category['value'] )) {
1937 1936
         if ( $this->getConfig( 'allowEmpty' ))
1938
-          $output .= $this->_createElement( 'CATEGORIES' );
1937
+            $output .= $this->_createElement( 'CATEGORIES' );
1939 1938
         continue;
1940
-      }
1941
-      $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1942
-      if( is_array( $category['value'] )) {
1939
+        }
1940
+        $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1941
+        if( is_array( $category['value'] )) {
1943 1942
         foreach( $category['value'] as $cix => $categoryPart )
1944
-          $category['value'][$cix] = $this->_strrep( $categoryPart );
1943
+            $category['value'][$cix] = $this->_strrep( $categoryPart );
1945 1944
         $content  = implode( ',', $category['value'] );
1946
-      }
1947
-      else
1945
+        }
1946
+        else
1948 1947
         $content  = $this->_strrep( $category['value'] );
1949
-      $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1948
+        $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1950 1949
     }
1951 1950
     return $output;
1952
-  }
1951
+    }
1953 1952
 /**
1954
- * set calendar component property categories
1955
- *
1956
- * @author Kjell-Inge Gustafsson <[email protected]>
1957
- * @since 2.5.1 - 2008-11-06
1958
- * @param mixed $value
1959
- * @param array $params, optional
1960
- * @param integer $index, optional
1961
- * @return bool
1962
- */
1963
-  function setCategories( $value, $params=FALSE, $index=FALSE ) {
1953
+     * set calendar component property categories
1954
+     *
1955
+     * @author Kjell-Inge Gustafsson <[email protected]>
1956
+     * @since 2.5.1 - 2008-11-06
1957
+     * @param mixed $value
1958
+     * @param array $params, optional
1959
+     * @param integer $index, optional
1960
+     * @return bool
1961
+     */
1962
+    function setCategories( $value, $params=FALSE, $index=FALSE ) {
1964 1963
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1965 1964
     $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1966 1965
     return TRUE;
1967
- }
1966
+    }
1968 1967
 /*********************************************************************************/
1969 1968
 /**
1970 1969
  * Property Name: CLASS
@@ -1976,27 +1975,27 @@  discard block
 block discarded – undo
1976 1975
  * @since 0.9.7 - 2006-11-20
1977 1976
  * @return string
1978 1977
  */
1979
-  function createClass() {
1978
+    function createClass() {
1980 1979
     if( empty( $this->class )) return FALSE;
1981 1980
     if( empty( $this->class['value'] ))
1982
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
1981
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
1983 1982
     $attributes = $this->_createParams( $this->class['params'] );
1984 1983
     return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1985
-  }
1984
+    }
1986 1985
 /**
1987
- * set calendar component property class
1988
- *
1989
- * @author Kjell-Inge Gustafsson <[email protected]>
1990
- * @since 2.4.8 - 2008-11-04
1991
- * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name
1992
- * @param array $params optional
1993
- * @return bool
1994
- */
1995
-  function setClass( $value, $params=FALSE ) {
1986
+     * set calendar component property class
1987
+     *
1988
+     * @author Kjell-Inge Gustafsson <[email protected]>
1989
+     * @since 2.4.8 - 2008-11-04
1990
+     * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name
1991
+     * @param array $params optional
1992
+     * @return bool
1993
+     */
1994
+    function setClass( $value, $params=FALSE ) {
1996 1995
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1997 1996
     $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1998 1997
     return TRUE;
1999
-  }
1998
+    }
2000 1999
 /*********************************************************************************/
2001 2000
 /**
2002 2001
  * Property Name: COMMENT
@@ -2008,35 +2007,35 @@  discard block
 block discarded – undo
2008 2007
  * @since 2.4.8 - 2008-10-22
2009 2008
  * @return string
2010 2009
  */
2011
-  function createComment() {
2010
+    function createComment() {
2012 2011
     if( empty( $this->comment )) return FALSE;
2013 2012
     $output = null;
2014 2013
     foreach( $this->comment as $commentPart ) {
2015
-      if( empty( $commentPart['value'] )) {
2014
+        if( empty( $commentPart['value'] )) {
2016 2015
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2017 2016
         continue;
2018
-      }
2019
-      $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
2020
-      $content    = $this->_strrep( $commentPart['value'] );
2021
-      $output    .= $this->_createElement( 'COMMENT', $attributes, $content );
2017
+        }
2018
+        $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
2019
+        $content    = $this->_strrep( $commentPart['value'] );
2020
+        $output    .= $this->_createElement( 'COMMENT', $attributes, $content );
2022 2021
     }
2023 2022
     return $output;
2024
-  }
2023
+    }
2025 2024
 /**
2026
- * set calendar component property comment
2027
- *
2028
- * @author Kjell-Inge Gustafsson <[email protected]>
2029
- * @since 2.5.1 - 2008-11-06
2030
- * @param string $value
2031
- * @param array $params, optional
2032
- * @param integer $index, optional
2033
- * @return bool
2034
- */
2035
-  function setComment( $value, $params=FALSE, $index=FALSE ) {
2025
+     * set calendar component property comment
2026
+     *
2027
+     * @author Kjell-Inge Gustafsson <[email protected]>
2028
+     * @since 2.5.1 - 2008-11-06
2029
+     * @param string $value
2030
+     * @param array $params, optional
2031
+     * @param integer $index, optional
2032
+     * @return bool
2033
+     */
2034
+    function setComment( $value, $params=FALSE, $index=FALSE ) {
2036 2035
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2037 2036
     $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2038 2037
     return TRUE;
2039
-  }
2038
+    }
2040 2039
 /*********************************************************************************/
2041 2040
 /**
2042 2041
  * Property Name: COMPLETED
@@ -2048,7 +2047,7 @@  discard block
 block discarded – undo
2048 2047
  * @since 2.4.8 - 2008-10-22
2049 2048
  * @return string
2050 2049
  */
2051
-  function createCompleted( ) {
2050
+    function createCompleted( ) {
2052 2051
     if( empty( $this->completed )) return FALSE;
2053 2052
     if( !isset( $this->completed['value']['year'] )  &&
2054 2053
         !isset( $this->completed['value']['month'] ) &&
@@ -2056,39 +2055,39 @@  discard block
 block discarded – undo
2056 2055
         !isset( $this->completed['value']['hour'] )  &&
2057 2056
         !isset( $this->completed['value']['min'] )   &&
2058 2057
         !isset( $this->completed['value']['sec'] ))
2059
-      if( $this->getConfig( 'allowEmpty' ))
2058
+        if( $this->getConfig( 'allowEmpty' ))
2060 2059
         return $this->_createElement( 'COMPLETED' );
2061
-      else return FALSE;
2060
+        else return FALSE;
2062 2061
     $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2063 2062
     $attributes = $this->_createParams( $this->completed['params'] );
2064 2063
     return $this->_createElement( 'COMPLETED', $attributes, $formatted );
2065
-  }
2064
+    }
2066 2065
 /**
2067
- * set calendar component property completed
2068
- *
2069
- * @author Kjell-Inge Gustafsson <[email protected]>
2070
- * @since 2.4.8 - 2008-10-23
2071
- * @param mixed $year
2072
- * @param mixed $month optional
2073
- * @param int $day optional
2074
- * @param int $hour optional
2075
- * @param int $min optional
2076
- * @param int $sec optional
2077
- * @param array $params optional
2078
- * @return bool
2079
- */
2080
-  function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2066
+     * set calendar component property completed
2067
+     *
2068
+     * @author Kjell-Inge Gustafsson <[email protected]>
2069
+     * @since 2.4.8 - 2008-10-23
2070
+     * @param mixed $year
2071
+     * @param mixed $month optional
2072
+     * @param int $day optional
2073
+     * @param int $hour optional
2074
+     * @param int $min optional
2075
+     * @param int $sec optional
2076
+     * @param array $params optional
2077
+     * @return bool
2078
+     */
2079
+    function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2081 2080
     if( empty( $year )) {
2082
-      if( $this->getConfig( 'allowEmpty' )) {
2081
+        if( $this->getConfig( 'allowEmpty' )) {
2083 2082
         $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2084 2083
         return TRUE;
2085
-      }
2086
-      else
2084
+        }
2085
+        else
2087 2086
         return FALSE;
2088 2087
     }
2089 2088
     $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2090 2089
     return TRUE;
2091
-  }
2090
+    }
2092 2091
 /*********************************************************************************/
2093 2092
 /**
2094 2093
  * Property Name: CONTACT
@@ -2100,34 +2099,34 @@  discard block
 block discarded – undo
2100 2099
  * @since 2.4.8 - 2008-10-23
2101 2100
  * @return string
2102 2101
  */
2103
-  function createContact() {
2102
+    function createContact() {
2104 2103
     if( empty( $this->contact )) return FALSE;
2105 2104
     $output = null;
2106 2105
     foreach( $this->contact as $contact ) {
2107
-      if( !empty( $contact['value'] )) {
2106
+        if( !empty( $contact['value'] )) {
2108 2107
         $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2109 2108
         $content    = $this->_strrep( $contact['value'] );
2110 2109
         $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2111
-      }
2112
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2110
+        }
2111
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2113 2112
     }
2114 2113
     return $output;
2115
-  }
2114
+    }
2116 2115
 /**
2117
- * set calendar component property contact
2118
- *
2119
- * @author Kjell-Inge Gustafsson <[email protected]>
2120
- * @since 2.5.1 - 2008-11-05
2121
- * @param string $value
2122
- * @param array $params, optional
2123
- * @param integer $index, optional
2124
- * @return bool
2125
- */
2126
-  function setContact( $value, $params=FALSE, $index=FALSE ) {
2116
+     * set calendar component property contact
2117
+     *
2118
+     * @author Kjell-Inge Gustafsson <[email protected]>
2119
+     * @since 2.5.1 - 2008-11-05
2120
+     * @param string $value
2121
+     * @param array $params, optional
2122
+     * @param integer $index, optional
2123
+     * @return bool
2124
+     */
2125
+    function setContact( $value, $params=FALSE, $index=FALSE ) {
2127 2126
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2128 2127
     $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2129 2128
     return TRUE;
2130
-  }
2129
+    }
2131 2130
 /*********************************************************************************/
2132 2131
 /**
2133 2132
  * Property Name: CREATED
@@ -2139,33 +2138,33 @@  discard block
 block discarded – undo
2139 2138
  * @since 2.4.8 - 2008-10-21
2140 2139
  * @return string
2141 2140
  */
2142
-  function createCreated() {
2141
+    function createCreated() {
2143 2142
     if( empty( $this->created )) return FALSE;
2144 2143
     $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2145 2144
     $attributes = $this->_createParams( $this->created['params'] );
2146 2145
     return $this->_createElement( 'CREATED', $attributes, $formatted );
2147
-  }
2146
+    }
2148 2147
 /**
2149
- * set calendar component property created
2150
- *
2151
- * @author Kjell-Inge Gustafsson <[email protected]>
2152
- * @since 2.4.8 - 2008-10-23
2153
- * @param mixed $year optional
2154
- * @param mixed $month optional
2155
- * @param int $day optional
2156
- * @param int $hour optional
2157
- * @param int $min optional
2158
- * @param int $sec optional
2159
- * @param mixed $params optional
2160
- * @return bool
2161
- */
2162
-  function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2148
+     * set calendar component property created
2149
+     *
2150
+     * @author Kjell-Inge Gustafsson <[email protected]>
2151
+     * @since 2.4.8 - 2008-10-23
2152
+     * @param mixed $year optional
2153
+     * @param mixed $month optional
2154
+     * @param int $day optional
2155
+     * @param int $hour optional
2156
+     * @param int $min optional
2157
+     * @param int $sec optional
2158
+     * @param mixed $params optional
2159
+     * @return bool
2160
+     */
2161
+    function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2163 2162
     if( !isset( $year )) {
2164
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2163
+        $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2165 2164
     }
2166 2165
     $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2167 2166
     return TRUE;
2168
-  }
2167
+    }
2169 2168
 /*********************************************************************************/
2170 2169
 /**
2171 2170
  * Property Name: DESCRIPTION
@@ -2177,34 +2176,34 @@  discard block
 block discarded – undo
2177 2176
  * @since 2.4.8 - 2008-10-22
2178 2177
  * @return string
2179 2178
  */
2180
-  function createDescription() {
2179
+    function createDescription() {
2181 2180
     if( empty( $this->description )) return FALSE;
2182 2181
     $output       = null;
2183 2182
     foreach( $this->description as $description ) {
2184
-      if( !empty( $description['value'] )) {
2183
+        if( !empty( $description['value'] )) {
2185 2184
         $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2186 2185
         $content    = $this->_strrep( $description['value'] );
2187 2186
         $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2188
-      }
2189
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2187
+        }
2188
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2190 2189
     }
2191 2190
     return $output;
2192
-  }
2191
+    }
2193 2192
 /**
2194
- * set calendar component property description
2195
- *
2196
- * @author Kjell-Inge Gustafsson <[email protected]>
2197
- * @since 2.5.1 - 2008-11-05
2198
- * @param string $value
2199
- * @param array $params, optional
2200
- * @param integer $index, optional
2201
- * @return bool
2202
- */
2203
-  function setDescription( $value, $params=FALSE, $index=FALSE ) {
2193
+     * set calendar component property description
2194
+     *
2195
+     * @author Kjell-Inge Gustafsson <[email protected]>
2196
+     * @since 2.5.1 - 2008-11-05
2197
+     * @param string $value
2198
+     * @param array $params, optional
2199
+     * @param integer $index, optional
2200
+     * @return bool
2201
+     */
2202
+    function setDescription( $value, $params=FALSE, $index=FALSE ) {
2204 2203
     if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2205 2204
     $this->_setMval( $this->description, $value, $params, FALSE, $index );
2206 2205
     return TRUE;
2207
-  }
2206
+    }
2208 2207
 /*********************************************************************************/
2209 2208
 /**
2210 2209
  * Property Name: DTEND
@@ -2216,7 +2215,7 @@  discard block
 block discarded – undo
2216 2215
  * @since 2.4.8 - 2008-10-21
2217 2216
  * @return string
2218 2217
  */
2219
-  function createDtend() {
2218
+    function createDtend() {
2220 2219
     if( empty( $this->dtend )) return FALSE;
2221 2220
     if( !isset( $this->dtend['value']['year'] )  &&
2222 2221
         !isset( $this->dtend['value']['month'] ) &&
@@ -2224,40 +2223,40 @@  discard block
 block discarded – undo
2224 2223
         !isset( $this->dtend['value']['hour'] )  &&
2225 2224
         !isset( $this->dtend['value']['min'] )   &&
2226 2225
         !isset( $this->dtend['value']['sec'] ))
2227
-      if( $this->getConfig( 'allowEmpty' ))
2226
+        if( $this->getConfig( 'allowEmpty' ))
2228 2227
         return $this->_createElement( 'DTEND' );
2229
-      else return FALSE;
2228
+        else return FALSE;
2230 2229
     $formatted  = $this->_format_date_time( $this->dtend['value'] );
2231 2230
     $attributes = $this->_createParams( $this->dtend['params'] );
2232 2231
     return $this->_createElement( 'DTEND', $attributes, $formatted );
2233
-  }
2232
+    }
2234 2233
 /**
2235
- * set calendar component property dtend
2236
- *
2237
- * @author Kjell-Inge Gustafsson <[email protected]>
2238
- * @since 2.4.8 - 2008-10-23
2239
- * @param mixed $year
2240
- * @param mixed $month optional
2241
- * @param int $day optional
2242
- * @param int $hour optional
2243
- * @param int $min optional
2244
- * @param int $sec optional
2245
- * @param string $tz optional
2246
- * @param array params optional
2247
- * @return bool
2248
- */
2249
-  function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2234
+     * set calendar component property dtend
2235
+     *
2236
+     * @author Kjell-Inge Gustafsson <[email protected]>
2237
+     * @since 2.4.8 - 2008-10-23
2238
+     * @param mixed $year
2239
+     * @param mixed $month optional
2240
+     * @param int $day optional
2241
+     * @param int $hour optional
2242
+     * @param int $min optional
2243
+     * @param int $sec optional
2244
+     * @param string $tz optional
2245
+     * @param array params optional
2246
+     * @return bool
2247
+     */
2248
+    function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2250 2249
     if( empty( $year )) {
2251
-      if( $this->getConfig( 'allowEmpty' )) {
2250
+        if( $this->getConfig( 'allowEmpty' )) {
2252 2251
         $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2253 2252
         return TRUE;
2254
-      }
2255
-      else
2253
+        }
2254
+        else
2256 2255
         return FALSE;
2257 2256
     }
2258 2257
     $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2259 2258
     return TRUE;
2260
-  }
2259
+    }
2261 2260
 /*********************************************************************************/
2262 2261
 /**
2263 2262
  * Property Name: DTSTAMP
@@ -2269,55 +2268,55 @@  discard block
 block discarded – undo
2269 2268
  * @since 2.4.4 - 2008-03-07
2270 2269
  * @return string
2271 2270
  */
2272
-  function createDtstamp() {
2271
+    function createDtstamp() {
2273 2272
     if( !isset( $this->dtstamp['value']['year'] )  &&
2274 2273
         !isset( $this->dtstamp['value']['month'] ) &&
2275 2274
         !isset( $this->dtstamp['value']['day'] )   &&
2276 2275
         !isset( $this->dtstamp['value']['hour'] )  &&
2277 2276
         !isset( $this->dtstamp['value']['min'] )   &&
2278 2277
         !isset( $this->dtstamp['value']['sec'] ))
2279
-      $this->_makeDtstamp();
2278
+        $this->_makeDtstamp();
2280 2279
     $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2281 2280
     $attributes = $this->_createParams( $this->dtstamp['params'] );
2282 2281
     return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
2283
-  }
2282
+    }
2284 2283
 /**
2285
- * computes datestamp for calendar component object instance dtstamp
2286
- *
2287
- * @author Kjell-Inge Gustafsson <[email protected]>
2288
- * @since 1.x.x - 2007-05-13
2289
- * @return void
2290
- */
2291
-  function _makeDtstamp() {
2284
+     * computes datestamp for calendar component object instance dtstamp
2285
+     *
2286
+     * @author Kjell-Inge Gustafsson <[email protected]>
2287
+     * @since 1.x.x - 2007-05-13
2288
+     * @return void
2289
+     */
2290
+    function _makeDtstamp() {
2292 2291
     $this->dtstamp['value'] = array( 'year'  => date( 'Y' )
2293
-                                   , 'month' => date( 'm' )
2294
-                                   , 'day'   => date( 'd' )
2295
-                                   , 'hour'  => date( 'H' )
2296
-                                   , 'min'   => date( 'i' )
2297
-                                   , 'sec'   => date( 's' ) - date( 'Z' ));
2292
+                                    , 'month' => date( 'm' )
2293
+                                    , 'day'   => date( 'd' )
2294
+                                    , 'hour'  => date( 'H' )
2295
+                                    , 'min'   => date( 'i' )
2296
+                                    , 'sec'   => date( 's' ) - date( 'Z' ));
2298 2297
     $this->dtstamp['params'] = null;
2299
-  }
2298
+    }
2300 2299
 /**
2301
- * set calendar component property dtstamp
2302
- *
2303
- * @author Kjell-Inge Gustafsson <[email protected]>
2304
- * @since 2.4.8 - 2008-10-23
2305
- * @param mixed $year
2306
- * @param mixed $month optional
2307
- * @param int $day optional
2308
- * @param int $hour optional
2309
- * @param int $min optional
2310
- * @param int $sec optional
2311
- * @param array $params optional
2312
- * @return TRUE
2313
- */
2314
-  function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2300
+     * set calendar component property dtstamp
2301
+     *
2302
+     * @author Kjell-Inge Gustafsson <[email protected]>
2303
+     * @since 2.4.8 - 2008-10-23
2304
+     * @param mixed $year
2305
+     * @param mixed $month optional
2306
+     * @param int $day optional
2307
+     * @param int $hour optional
2308
+     * @param int $min optional
2309
+     * @param int $sec optional
2310
+     * @param array $params optional
2311
+     * @return TRUE
2312
+     */
2313
+    function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315 2314
     if( empty( $year ))
2316
-      $this->_makeDtstamp();
2315
+        $this->_makeDtstamp();
2317 2316
     else
2318
-      $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2317
+        $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2319 2318
     return TRUE;
2320
-  }
2319
+    }
2321 2320
 /*********************************************************************************/
2322 2321
 /**
2323 2322
  * Property Name: DTSTART
@@ -2329,7 +2328,7 @@  discard block
 block discarded – undo
2329 2328
  * @since 2.4.16 - 2008-10-26
2330 2329
  * @return string
2331 2330
  */
2332
-  function createDtstart() {
2331
+    function createDtstart() {
2333 2332
     if( empty( $this->dtstart )) return FALSE;
2334 2333
     if( !isset( $this->dtstart['value']['year'] )  &&
2335 2334
         !isset( $this->dtstart['value']['month'] ) &&
@@ -2338,41 +2337,41 @@  discard block
 block discarded – undo
2338 2337
         !isset( $this->dtstart['value']['min'] )   &&
2339 2338
         !isset( $this->dtstart['value']['sec'] ))
2340 2339
     if( $this->getConfig( 'allowEmpty' ))
2341
-      return $this->_createElement( 'DTSTART' );
2340
+        return $this->_createElement( 'DTSTART' );
2342 2341
     else return FALSE;
2343 2342
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2344
-      unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2343
+        unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2345 2344
     $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2346 2345
     $attributes = $this->_createParams( $this->dtstart['params'] );
2347 2346
     return $this->_createElement( 'DTSTART', $attributes, $formatted );
2348
-  }
2347
+    }
2349 2348
 /**
2350
- * set calendar component property dtstart
2351
- *
2352
- * @author Kjell-Inge Gustafsson <[email protected]>
2353
- * @since 2.4.16 - 2008-11-04
2354
- * @param mixed $year
2355
- * @param mixed $month optional
2356
- * @param int $day optional
2357
- * @param int $hour optional
2358
- * @param int $min optional
2359
- * @param int $sec optional
2360
- * @param string $tz optional
2361
- * @param array $params optional
2362
- * @return bool
2363
- */
2364
-  function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2349
+     * set calendar component property dtstart
2350
+     *
2351
+     * @author Kjell-Inge Gustafsson <[email protected]>
2352
+     * @since 2.4.16 - 2008-11-04
2353
+     * @param mixed $year
2354
+     * @param mixed $month optional
2355
+     * @param int $day optional
2356
+     * @param int $hour optional
2357
+     * @param int $min optional
2358
+     * @param int $sec optional
2359
+     * @param string $tz optional
2360
+     * @param array $params optional
2361
+     * @return bool
2362
+     */
2363
+    function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2365 2364
     if( empty( $year )) {
2366
-      if( $this->getConfig( 'allowEmpty' )) {
2365
+        if( $this->getConfig( 'allowEmpty' )) {
2367 2366
         $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2368 2367
         return TRUE;
2369
-      }
2370
-      else
2368
+        }
2369
+        else
2371 2370
         return FALSE;
2372 2371
     }
2373 2372
     $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2374 2373
     return TRUE;
2375
-  }
2374
+    }
2376 2375
 /*********************************************************************************/
2377 2376
 /**
2378 2377
  * Property Name: DUE
@@ -2384,7 +2383,7 @@  discard block
 block discarded – undo
2384 2383
  * @since 2.4.8 - 2008-10-22
2385 2384
  * @return string
2386 2385
  */
2387
-  function createDue() {
2386
+    function createDue() {
2388 2387
     if( empty( $this->due )) return FALSE;
2389 2388
     if( !isset( $this->due['value']['year'] )  &&
2390 2389
         !isset( $this->due['value']['month'] ) &&
@@ -2392,39 +2391,39 @@  discard block
 block discarded – undo
2392 2391
         !isset( $this->due['value']['hour'] )  &&
2393 2392
         !isset( $this->due['value']['min'] )   &&
2394 2393
         !isset( $this->due['value']['sec'] ))
2395
-      if( $this->getConfig( 'allowEmpty' ))
2394
+        if( $this->getConfig( 'allowEmpty' ))
2396 2395
         return $this->_createElement( 'DUE' );
2397
-      else return FALSE;
2396
+        else return FALSE;
2398 2397
     $formatted  = $this->_format_date_time( $this->due['value'] );
2399 2398
     $attributes = $this->_createParams( $this->due['params'] );
2400 2399
     return $this->_createElement( 'DUE', $attributes, $formatted );
2401
-  }
2400
+    }
2402 2401
 /**
2403
- * set calendar component property due
2404
- *
2405
- * @author Kjell-Inge Gustafsson <[email protected]>
2406
- * @since 2.4.8 - 2008-11-04
2407
- * @param mixed $year
2408
- * @param mixed $month optional
2409
- * @param int $day optional
2410
- * @param int $hour optional
2411
- * @param int $min optional
2412
- * @param int $sec optional
2413
- * @param array $params optional
2414
- * @return bool
2415
- */
2416
-  function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2402
+     * set calendar component property due
2403
+     *
2404
+     * @author Kjell-Inge Gustafsson <[email protected]>
2405
+     * @since 2.4.8 - 2008-11-04
2406
+     * @param mixed $year
2407
+     * @param mixed $month optional
2408
+     * @param int $day optional
2409
+     * @param int $hour optional
2410
+     * @param int $min optional
2411
+     * @param int $sec optional
2412
+     * @param array $params optional
2413
+     * @return bool
2414
+     */
2415
+    function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2417 2416
     if( empty( $year )) {
2418
-      if( $this->getConfig( 'allowEmpty' )) {
2417
+        if( $this->getConfig( 'allowEmpty' )) {
2419 2418
         $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2420 2419
         return TRUE;
2421
-      }
2422
-      else
2420
+        }
2421
+        else
2423 2422
         return FALSE;
2424 2423
     }
2425 2424
     $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2426 2425
     return TRUE;
2427
-  }
2426
+    }
2428 2427
 /*********************************************************************************/
2429 2428
 /**
2430 2429
  * Property Name: DURATION
@@ -2436,48 +2435,48 @@  discard block
 block discarded – undo
2436 2435
  * @since 2.4.8 - 2008-10-21
2437 2436
  * @return string
2438 2437
  */
2439
-  function createDuration() {
2438
+    function createDuration() {
2440 2439
     if( empty( $this->duration )) return FALSE;
2441 2440
     if( !isset( $this->duration['value']['week'] ) &&
2442 2441
         !isset( $this->duration['value']['day'] )  &&
2443 2442
         !isset( $this->duration['value']['hour'] ) &&
2444 2443
         !isset( $this->duration['value']['min'] )  &&
2445 2444
         !isset( $this->duration['value']['sec'] ))
2446
-      if( $this->getConfig( 'allowEmpty' ))
2445
+        if( $this->getConfig( 'allowEmpty' ))
2447 2446
         return $this->_createElement( 'DURATION', array(), null );
2448
-      else return FALSE;
2447
+        else return FALSE;
2449 2448
     $attributes = $this->_createParams( $this->duration['params'] );
2450 2449
     return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2451
-  }
2450
+    }
2452 2451
 /**
2453
- * set calendar component property duration
2454
- *
2455
- * @author Kjell-Inge Gustafsson <[email protected]>
2456
- * @since 2.4.8 - 2008-11-04
2457
- * @param mixed $week
2458
- * @param mixed $day optional
2459
- * @param int $hour optional
2460
- * @param int $min optional
2461
- * @param int $sec optional
2462
- * @param array $params optional
2463
- * @return bool
2464
- */
2465
-  function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2452
+     * set calendar component property duration
2453
+     *
2454
+     * @author Kjell-Inge Gustafsson <[email protected]>
2455
+     * @since 2.4.8 - 2008-11-04
2456
+     * @param mixed $week
2457
+     * @param mixed $day optional
2458
+     * @param int $hour optional
2459
+     * @param int $min optional
2460
+     * @param int $sec optional
2461
+     * @param array $params optional
2462
+     * @return bool
2463
+     */
2464
+    function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2466 2465
     if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2467 2466
     if( is_array( $week ) && ( 1 <= count( $week )))
2468
-      $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2467
+        $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2469 2468
     elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2470
-      $week = trim( $week );
2471
-      if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2469
+        $week = trim( $week );
2470
+        if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2472 2471
         $week = substr( $week, 1 );
2473
-      $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2472
+        $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2474 2473
     }
2475 2474
     elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2476
-      return FALSE;
2475
+        return FALSE;
2477 2476
     else
2478
-      $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2477
+        $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2479 2478
     return TRUE;
2480
-  }
2479
+    }
2481 2480
 /*********************************************************************************/
2482 2481
 /**
2483 2482
  * Property Name: EXDATE
@@ -2489,57 +2488,57 @@  discard block
 block discarded – undo
2489 2488
  * @since 2.4.8 - 2008-10-22
2490 2489
  * @return string
2491 2490
  */
2492
-  function createExdate() {
2491
+    function createExdate() {
2493 2492
     if( empty( $this->exdate )) return FALSE;
2494 2493
     $output = null;
2495 2494
     foreach( $this->exdate as $ex => $theExdate ) {
2496
-      if( empty( $theExdate['value'] )) {
2495
+        if( empty( $theExdate['value'] )) {
2497 2496
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2498 2497
         continue;
2499
-      }
2500
-      $content = $attributes = null;
2501
-      foreach( $theExdate['value'] as $eix => $exdatePart ) {
2498
+        }
2499
+        $content = $attributes = null;
2500
+        foreach( $theExdate['value'] as $eix => $exdatePart ) {
2502 2501
         $parno = count( $exdatePart );
2503 2502
         $formatted = $this->_format_date_time( $exdatePart, $parno );
2504 2503
         if( isset( $theExdate['params']['TZID'] ))
2505
-          $formatted = str_replace( 'Z', '', $formatted);
2504
+            $formatted = str_replace( 'Z', '', $formatted);
2506 2505
         if( 0 < $eix ) {
2507
-          if( isset( $theExdate['value'][0]['tz'] )) {
2506
+            if( isset( $theExdate['value'][0]['tz'] )) {
2508 2507
             if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2509 2508
                ( 'Z' == $theExdate['value'][0]['tz'] )) {
2510
-              if( 'Z' != substr( $formatted, -1 ))
2509
+                if( 'Z' != substr( $formatted, -1 ))
2511 2510
                 $formatted .= 'Z';
2512 2511
             }
2513 2512
             else
2514
-              $formatted = str_replace( 'Z', '', $formatted );
2515
-          }
2516
-          else
2513
+                $formatted = str_replace( 'Z', '', $formatted );
2514
+            }
2515
+            else
2517 2516
             $formatted = str_replace( 'Z', '', $formatted );
2518 2517
         }
2519 2518
         $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2520
-      }
2521
-      $attributes .= $this->_createParams( $theExdate['params'] );
2522
-      $output .= $this->_createElement( 'EXDATE', $attributes, $content );
2519
+        }
2520
+        $attributes .= $this->_createParams( $theExdate['params'] );
2521
+        $output .= $this->_createElement( 'EXDATE', $attributes, $content );
2523 2522
     }
2524 2523
     return $output;
2525
-  }
2524
+    }
2526 2525
 /**
2527
- * set calendar component property exdate
2528
- *
2529
- * @author Kjell-Inge Gustafsson <[email protected]>
2530
- * @since 2.5.1 - 2008-11-05
2531
- * @param array exdates
2532
- * @param array $params, optional
2533
- * @param integer $index, optional
2534
- * @return bool
2535
- */
2536
-  function setExdate( $exdates, $params=FALSE, $index=FALSE ) {
2526
+     * set calendar component property exdate
2527
+     *
2528
+     * @author Kjell-Inge Gustafsson <[email protected]>
2529
+     * @since 2.5.1 - 2008-11-05
2530
+     * @param array exdates
2531
+     * @param array $params, optional
2532
+     * @param integer $index, optional
2533
+     * @return bool
2534
+     */
2535
+    function setExdate( $exdates, $params=FALSE, $index=FALSE ) {
2537 2536
     if( empty( $exdates )) {
2538
-      if( $this->getConfig( 'allowEmpty' )) {
2537
+        if( $this->getConfig( 'allowEmpty' )) {
2539 2538
         $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2540 2539
         return TRUE;
2541
-      }
2542
-      else
2540
+        }
2541
+        else
2543 2542
         return FALSE;
2544 2543
     }
2545 2544
     $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
@@ -2547,32 +2546,32 @@  discard block
 block discarded – undo
2547 2546
     $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2548 2547
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2549 2548
     foreach( $exdates as $eix => $theExdate ) {
2550
-      if( $this->_isArrayTimestampDate( $theExdate ))
2549
+        if( $this->_isArrayTimestampDate( $theExdate ))
2551 2550
         $exdatea = $this->_timestamp2date( $theExdate, $parno );
2552
-      elseif(  is_array( $theExdate ))
2551
+        elseif(  is_array( $theExdate ))
2553 2552
         $exdatea = $this->_date_time_array( $theExdate, $parno );
2554
-      elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2553
+        elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2555 2554
         $exdatea = $this->_date_time_string( $theExdate, $parno );
2556
-      if( 3 == $parno )
2555
+        if( 3 == $parno )
2557 2556
         unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2558
-      elseif( isset( $exdatea['tz'] ))
2557
+        elseif( isset( $exdatea['tz'] ))
2559 2558
         $exdatea['tz'] = (string) $exdatea['tz'];
2560
-      if(  isset( $input['params']['TZID'] ) ||
2559
+        if(  isset( $input['params']['TZID'] ) ||
2561 2560
          ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2562 2561
          ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2563 2562
          ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2564 2563
         unset( $exdatea['tz'] );
2565
-      $input['value'][] = $exdatea;
2564
+        $input['value'][] = $exdatea;
2566 2565
     }
2567 2566
     if( 0 >= count( $input['value'] ))
2568
-      return FALSE;
2567
+        return FALSE;
2569 2568
     if( 3 == $parno ) {
2570
-      $input['params']['VALUE'] = 'DATE';
2571
-      unset( $input['params']['TZID'] );
2569
+        $input['params']['VALUE'] = 'DATE';
2570
+        unset( $input['params']['TZID'] );
2572 2571
     }
2573 2572
     $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index );
2574 2573
     return TRUE;
2575
-  }
2574
+    }
2576 2575
 /*********************************************************************************/
2577 2576
 /**
2578 2577
  * Property Name: EXRULE
@@ -2584,25 +2583,25 @@  discard block
 block discarded – undo
2584 2583
  * @since 2.4.8 - 2008-10-22
2585 2584
  * @return string
2586 2585
  */
2587
-  function createExrule() {
2586
+    function createExrule() {
2588 2587
     if( empty( $this->exrule )) return FALSE;
2589 2588
     return $this->_format_recur( 'EXRULE', $this->exrule );
2590
-  }
2589
+    }
2591 2590
 /**
2592
- * set calendar component property exdate
2593
- *
2594
- * @author Kjell-Inge Gustafsson <[email protected]>
2595
- * @since 2.5.1 - 2008-11-05
2596
- * @param array $exruleset
2597
- * @param array $params, optional
2598
- * @param integer $index, optional
2599
- * @return bool
2600
- */
2601
-  function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2591
+     * set calendar component property exdate
2592
+     *
2593
+     * @author Kjell-Inge Gustafsson <[email protected]>
2594
+     * @since 2.5.1 - 2008-11-05
2595
+     * @param array $exruleset
2596
+     * @param array $params, optional
2597
+     * @param integer $index, optional
2598
+     * @return bool
2599
+     */
2600
+    function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2602 2601
     if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2603 2602
     $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2604 2603
     return TRUE;
2605
-  }
2604
+    }
2606 2605
 /*********************************************************************************/
2607 2606
 /**
2608 2607
  * Property Name: FREEBUSY
@@ -2614,110 +2613,110 @@  discard block
 block discarded – undo
2614 2613
  * @since 2.4.8 - 2008-10-22
2615 2614
  * @return string
2616 2615
  */
2617
-  function createFreebusy() {
2616
+    function createFreebusy() {
2618 2617
     if( empty( $this->freebusy )) return FALSE;
2619 2618
     $output = null;
2620 2619
     foreach( $this->freebusy as $freebusyPart ) {
2621
-      if( empty( $freebusyPart['value'] )) {
2620
+        if( empty( $freebusyPart['value'] )) {
2622 2621
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2623 2622
         continue;
2624
-      }
2625
-      $attributes = $content = null;
2626
-      if( isset( $freebusyPart['value']['fbtype'] )) {
2623
+        }
2624
+        $attributes = $content = null;
2625
+        if( isset( $freebusyPart['value']['fbtype'] )) {
2627 2626
         $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2628 2627
         unset( $freebusyPart['value']['fbtype'] );
2629 2628
         $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2630
-      }
2631
-      else
2629
+        }
2630
+        else
2632 2631
         $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2633
-      $attributes .= $this->_createParams( $freebusyPart['params'] );
2634
-      $fno = 1;
2635
-      $cnt = count( $freebusyPart['value']);
2636
-      foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) {
2632
+        $attributes .= $this->_createParams( $freebusyPart['params'] );
2633
+        $fno = 1;
2634
+        $cnt = count( $freebusyPart['value']);
2635
+        foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) {
2637 2636
         $formatted   = $this->_format_date_time( $freebusyPeriod[0] );
2638 2637
         $content .= $formatted;
2639 2638
         $content .= '/';
2640 2639
         $cnt2 = count( $freebusyPeriod[1]);
2641 2640
         if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2642
-          $cnt2 = 7;
2641
+            $cnt2 = 7;
2643 2642
         elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2644
-          $cnt2 = 5;
2643
+            $cnt2 = 5;
2645 2644
         if(( 7 == $cnt2 )   &&    // period=  -> date-time
2646 2645
             isset( $freebusyPeriod[1]['year'] )  &&
2647 2646
             isset( $freebusyPeriod[1]['month'] ) &&
2648 2647
             isset( $freebusyPeriod[1]['day'] )) {
2649
-          $content .= $this->_format_date_time( $freebusyPeriod[1] );
2648
+            $content .= $this->_format_date_time( $freebusyPeriod[1] );
2650 2649
         }
2651 2650
         else {                                  // period=  -> dur-time
2652
-          $content .= $this->_format_duration( $freebusyPeriod[1] );
2651
+            $content .= $this->_format_duration( $freebusyPeriod[1] );
2653 2652
         }
2654 2653
         if( $fno < $cnt )
2655
-          $content .= ',';
2654
+            $content .= ',';
2656 2655
         $fno++;
2657
-      }
2658
-      $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
2656
+        }
2657
+        $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
2659 2658
     }
2660 2659
     return $output;
2661
-  }
2660
+    }
2662 2661
 /**
2663
- * set calendar component property freebusy
2664
- *
2665
- * @author Kjell-Inge Gustafsson <[email protected]>
2666
- * @since 2.5.1 - 2008-11-05
2667
- * @param string $fbType
2668
- * @param array $fbValues
2669
- * @param array $params, optional
2670
- * @param integer $index, optional
2671
- * @return bool
2672
- */
2673
-  function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) {
2662
+     * set calendar component property freebusy
2663
+     *
2664
+     * @author Kjell-Inge Gustafsson <[email protected]>
2665
+     * @since 2.5.1 - 2008-11-05
2666
+     * @param string $fbType
2667
+     * @param array $fbValues
2668
+     * @param array $params, optional
2669
+     * @param integer $index, optional
2670
+     * @return bool
2671
+     */
2672
+    function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) {
2674 2673
     if( empty( $fbValues )) {
2675
-      if( $this->getConfig( 'allowEmpty' )) {
2674
+        if( $this->getConfig( 'allowEmpty' )) {
2676 2675
         $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2677 2676
         return TRUE;
2678
-      }
2679
-      else
2677
+        }
2678
+        else
2680 2679
         return FALSE;
2681 2680
     }
2682 2681
     $fbType = strtoupper( $fbType );
2683 2682
     if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2684 2683
        ( 'X-' != substr( $fbType, 0, 2 )))
2685
-      $fbType = 'BUSY';
2684
+        $fbType = 'BUSY';
2686 2685
     $input = array( 'fbtype' => $fbType );
2687 2686
     foreach( $fbValues as $fbPeriod ) {   // periods => period
2688
-      $freebusyPeriod = array();
2689
-      foreach( $fbPeriod as $fbMember ) { // pairs => singlepart
2687
+        $freebusyPeriod = array();
2688
+        foreach( $fbPeriod as $fbMember ) { // pairs => singlepart
2690 2689
         $freebusyPairMember = array();
2691 2690
         if( is_array( $fbMember )) {
2692
-          if( $this->_isArrayDate( $fbMember )) { // date-time value
2691
+            if( $this->_isArrayDate( $fbMember )) { // date-time value
2693 2692
             $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2694 2693
             $freebusyPairMember['tz'] = 'Z';
2695
-          }
2696
-          elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2694
+            }
2695
+            elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2697 2696
             $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2698 2697
             $freebusyPairMember['tz'] = 'Z';
2699
-          }
2700
-          else {                                         // array format duration
2698
+            }
2699
+            else {                                         // array format duration
2701 2700
             $freebusyPairMember = $this->_duration_array( $fbMember );
2702
-          }
2701
+            }
2703 2702
         }
2704 2703
         elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2705 2704
                ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2706
-          if( 'P' != $fbMember{0} )
2705
+            if( 'P' != $fbMember{0} )
2707 2706
             $fbmember = substr( $fbMember, 1 );
2708
-          $freebusyPairMember = $this->_duration_string( $fbMember );
2707
+            $freebusyPairMember = $this->_duration_string( $fbMember );
2709 2708
         }
2710 2709
         elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2711
-          $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2712
-          $freebusyPairMember['tz'] = 'Z';
2710
+            $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2711
+            $freebusyPairMember['tz'] = 'Z';
2713 2712
         }
2714 2713
         $freebusyPeriod[]   = $freebusyPairMember;
2715
-      }
2716
-      $input[]              = $freebusyPeriod;
2714
+        }
2715
+        $input[]              = $freebusyPeriod;
2717 2716
     }
2718 2717
     $this->_setMval( $this->freebusy, $input, $params, FALSE, $index );
2719 2718
     return TRUE;
2720
-  }
2719
+    }
2721 2720
 /*********************************************************************************/
2722 2721
 /**
2723 2722
  * Property Name: GEO
@@ -2729,40 +2728,40 @@  discard block
 block discarded – undo
2729 2728
  * @since 2.4.8 - 2008-10-21
2730 2729
  * @return string
2731 2730
  */
2732
-  function createGeo() {
2731
+    function createGeo() {
2733 2732
     if( empty( $this->geo )) return FALSE;
2734 2733
     if( empty( $this->geo['value'] ))
2735
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
2734
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
2736 2735
     $attributes = $this->_createParams( $this->geo['params'] );
2737 2736
     $content    = null;
2738 2737
     $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
2739 2738
     $content   .= ';';
2740 2739
     $content   .= number_format( (float) $this->geo['value']['longitude'], 6, '.', '');
2741 2740
     return $this->_createElement( 'GEO', $attributes, $content );
2742
-  }
2741
+    }
2743 2742
 /**
2744
- * set calendar component property geo
2745
- *
2746
- * @author Kjell-Inge Gustafsson <[email protected]>
2747
- * @since 2.4.8 - 2008-11-04
2748
- * @param float $latitude
2749
- * @param float $longitude
2750
- * @param array $params optional
2751
- * @return bool
2752
- */
2753
-  function setGeo( $latitude, $longitude, $params=FALSE ) {
2743
+     * set calendar component property geo
2744
+     *
2745
+     * @author Kjell-Inge Gustafsson <[email protected]>
2746
+     * @since 2.4.8 - 2008-11-04
2747
+     * @param float $latitude
2748
+     * @param float $longitude
2749
+     * @param array $params optional
2750
+     * @return bool
2751
+     */
2752
+    function setGeo( $latitude, $longitude, $params=FALSE ) {
2754 2753
     if( !empty( $latitude ) && !empty( $longitude )) {
2755
-      if( !is_array( $this->geo )) $this->geo = array();
2756
-      $this->geo['value']['latitude']  = $latitude;
2757
-      $this->geo['value']['longitude'] = $longitude;
2758
-      $this->geo['params'] = $this->_setParams( $params );
2754
+        if( !is_array( $this->geo )) $this->geo = array();
2755
+        $this->geo['value']['latitude']  = $latitude;
2756
+        $this->geo['value']['longitude'] = $longitude;
2757
+        $this->geo['params'] = $this->_setParams( $params );
2759 2758
     }
2760 2759
     elseif( $this->getConfig( 'allowEmpty' ))
2761
-      $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2760
+        $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2762 2761
     else
2763
-      return FALSE;
2762
+        return FALSE;
2764 2763
     return TRUE;
2765
-  }
2764
+    }
2766 2765
 /*********************************************************************************/
2767 2766
 /**
2768 2767
  * Property Name: LAST-MODIFIED
@@ -2774,32 +2773,32 @@  discard block
 block discarded – undo
2774 2773
  * @since 2.4.8 - 2008-10-21
2775 2774
  * @return string
2776 2775
  */
2777
-  function createLastModified() {
2776
+    function createLastModified() {
2778 2777
     if( empty( $this->lastmodified )) return FALSE;
2779 2778
     $attributes = $this->_createParams( $this->lastmodified['params'] );
2780 2779
     $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2781 2780
     return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
2782
-  }
2781
+    }
2783 2782
 /**
2784
- * set calendar component property completed
2785
- *
2786
- * @author Kjell-Inge Gustafsson <[email protected]>
2787
- * @since 2.4.8 - 2008-10-23
2788
- * @param mixed $year optional
2789
- * @param mixed $month optional
2790
- * @param int $day optional
2791
- * @param int $hour optional
2792
- * @param int $min optional
2793
- * @param int $sec optional
2794
- * @param array $params optional
2795
- * @return boll
2796
- */
2797
-  function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2783
+     * set calendar component property completed
2784
+     *
2785
+     * @author Kjell-Inge Gustafsson <[email protected]>
2786
+     * @since 2.4.8 - 2008-10-23
2787
+     * @param mixed $year optional
2788
+     * @param mixed $month optional
2789
+     * @param int $day optional
2790
+     * @param int $hour optional
2791
+     * @param int $min optional
2792
+     * @param int $sec optional
2793
+     * @param array $params optional
2794
+     * @return boll
2795
+     */
2796
+    function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798 2797
     if( empty( $year ))
2799
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2798
+        $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2800 2799
     $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2801 2800
     return TRUE;
2802
-  }
2801
+    }
2803 2802
 /*********************************************************************************/
2804 2803
 /**
2805 2804
  * Property Name: LOCATION
@@ -2811,28 +2810,28 @@  discard block
 block discarded – undo
2811 2810
  * @since 2.4.8 - 2008-10-22
2812 2811
  * @return string
2813 2812
  */
2814
-  function createLocation() {
2813
+    function createLocation() {
2815 2814
     if( empty( $this->location )) return FALSE;
2816 2815
     if( empty( $this->location['value'] ))
2817
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
2816
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
2818 2817
     $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2819 2818
     $content    = $this->_strrep( $this->location['value'] );
2820 2819
     return $this->_createElement( 'LOCATION', $attributes, $content );
2821
-  }
2820
+    }
2822 2821
 /**
2823
- * set calendar component property location
2822
+     * set calendar component property location
2824 2823
  '
2825
- * @author Kjell-Inge Gustafsson <[email protected]>
2826
- * @since 2.4.8 - 2008-11-04
2827
- * @param string $value
2828
- * @param array params optional
2829
- * @return bool
2830
- */
2831
-  function setLocation( $value, $params=FALSE ) {
2824
+     * @author Kjell-Inge Gustafsson <[email protected]>
2825
+     * @since 2.4.8 - 2008-11-04
2826
+     * @param string $value
2827
+     * @param array params optional
2828
+     * @return bool
2829
+     */
2830
+    function setLocation( $value, $params=FALSE ) {
2832 2831
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2833 2832
     $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2834 2833
     return TRUE;
2835
-  }
2834
+    }
2836 2835
 /*********************************************************************************/
2837 2836
 /**
2838 2837
  * Property Name: ORGANIZER
@@ -2844,35 +2843,35 @@  discard block
 block discarded – undo
2844 2843
  * @since 2.4.8 - 2008-10-21
2845 2844
  * @return string
2846 2845
  */
2847
-  function createOrganizer() {
2846
+    function createOrganizer() {
2848 2847
     if( empty( $this->organizer )) return FALSE;
2849 2848
     if( empty( $this->organizer['value'] ))
2850
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
2849
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
2851 2850
     $attributes = $this->_createParams( $this->organizer['params']
2852
-                                      , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2851
+                                        , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2853 2852
     $content    = 'MAILTO:'.$this->organizer['value'];
2854 2853
     return $this->_createElement( 'ORGANIZER', $attributes, $content );
2855
-  }
2854
+    }
2856 2855
 /**
2857
- * set calendar component property organizer
2858
- *
2859
- * @author Kjell-Inge Gustafsson <[email protected]>
2860
- * @since 2.4.8 - 2008-11-04
2861
- * @param string $value
2862
- * @param array params optional
2863
- * @return bool
2864
- */
2865
-  function setOrganizer( $value, $params=FALSE ) {
2856
+     * set calendar component property organizer
2857
+     *
2858
+     * @author Kjell-Inge Gustafsson <[email protected]>
2859
+     * @since 2.4.8 - 2008-11-04
2860
+     * @param string $value
2861
+     * @param array params optional
2862
+     * @return bool
2863
+     */
2864
+    function setOrganizer( $value, $params=FALSE ) {
2866 2865
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2867 2866
     $value = str_replace ( 'MAILTO:', '', $value );
2868 2867
     $value = str_replace ( 'mailto:', '', $value );
2869 2868
     $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2870 2869
     if( isset( $this->organizer['params']['SENT-BY'] )) {
2871
-      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2870
+        if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2872 2871
         $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
2873 2872
     }
2874 2873
     return TRUE;
2875
-  }
2874
+    }
2876 2875
 /*********************************************************************************/
2877 2876
 /**
2878 2877
  * Property Name: PERCENT-COMPLETE
@@ -2884,27 +2883,27 @@  discard block
 block discarded – undo
2884 2883
  * @since 2.4.8 - 2008-10-22
2885 2884
  * @return string
2886 2885
  */
2887
-  function createPercentComplete() {
2886
+    function createPercentComplete() {
2888 2887
     if( empty( $this->percentcomplete )) return FALSE;
2889 2888
     if( empty( $this->percentcomplete['value'] ))
2890
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
2889
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
2891 2890
     $attributes = $this->_createParams( $this->percentcomplete['params'] );
2892 2891
     return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2893
-  }
2892
+    }
2894 2893
 /**
2895
- * set calendar component property percent-complete
2896
- *
2897
- * @author Kjell-Inge Gustafsson <[email protected]>
2898
- * @since 2.4.8 - 2008-11-04
2899
- * @param int $value
2900
- * @param array $params optional
2901
- * @return bool
2902
- */
2903
-  function setPercentComplete( $value, $params=FALSE ) {
2894
+     * set calendar component property percent-complete
2895
+     *
2896
+     * @author Kjell-Inge Gustafsson <[email protected]>
2897
+     * @since 2.4.8 - 2008-11-04
2898
+     * @param int $value
2899
+     * @param array $params optional
2900
+     * @return bool
2901
+     */
2902
+    function setPercentComplete( $value, $params=FALSE ) {
2904 2903
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2905 2904
     $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2906 2905
     return TRUE;
2907
-  }
2906
+    }
2908 2907
 /*********************************************************************************/
2909 2908
 /**
2910 2909
  * Property Name: PRIORITY
@@ -2916,27 +2915,27 @@  discard block
 block discarded – undo
2916 2915
  * @since 2.4.8 - 2008-10-21
2917 2916
  * @return string
2918 2917
  */
2919
-  function createPriority() {
2918
+    function createPriority() {
2920 2919
     if( empty( $this->priority )) return FALSE;
2921 2920
     if( empty( $this->priority['value'] ))
2922
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
2921
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
2923 2922
     $attributes = $this->_createParams( $this->priority['params'] );
2924 2923
     return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2925
-  }
2924
+    }
2926 2925
 /**
2927
- * set calendar component property priority
2928
- *
2929
- * @author Kjell-Inge Gustafsson <[email protected]>
2930
- * @since 2.4.8 - 2008-11-04
2931
- * @param int $value
2932
- * @param array $params optional
2933
- * @return bool
2934
- */
2935
-  function setPriority( $value, $params=FALSE  ) {
2926
+     * set calendar component property priority
2927
+     *
2928
+     * @author Kjell-Inge Gustafsson <[email protected]>
2929
+     * @since 2.4.8 - 2008-11-04
2930
+     * @param int $value
2931
+     * @param array $params optional
2932
+     * @return bool
2933
+     */
2934
+    function setPriority( $value, $params=FALSE  ) {
2936 2935
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2937 2936
     $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2938 2937
     return TRUE;
2939
-  }
2938
+    }
2940 2939
 /*********************************************************************************/
2941 2940
 /**
2942 2941
  * Property Name: RDATE
@@ -2948,118 +2947,118 @@  discard block
 block discarded – undo
2948 2947
  * @since 2.4.16 - 2008-10-26
2949 2948
  * @return string
2950 2949
  */
2951
-  function createRdate() {
2950
+    function createRdate() {
2952 2951
     if( empty( $this->rdate )) return FALSE;
2953 2952
     $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2954 2953
     $output = null;
2955 2954
     if( $utctime  )
2956
-      unset( $this->rdate['params']['TZID'] );
2955
+        unset( $this->rdate['params']['TZID'] );
2957 2956
     foreach( $this->rdate as $theRdate ) {
2958
-      if( empty( $theRdate['value'] )) {
2957
+        if( empty( $theRdate['value'] )) {
2959 2958
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
2960 2959
         continue;
2961
-      }
2962
-      if( $utctime  )
2960
+        }
2961
+        if( $utctime  )
2963 2962
         unset( $theRdate['params']['TZID'] );
2964
-      $attributes = $this->_createParams( $theRdate['params'] );
2965
-      $cnt = count( $theRdate['value'] );
2966
-      $content = null;
2967
-      $rno = 1;
2968
-      foreach( $theRdate['value'] as $rpix => $rdatePart ) {
2963
+        $attributes = $this->_createParams( $theRdate['params'] );
2964
+        $cnt = count( $theRdate['value'] );
2965
+        $content = null;
2966
+        $rno = 1;
2967
+        foreach( $theRdate['value'] as $rpix => $rdatePart ) {
2969 2968
         $contentPart = null;
2970 2969
         if( is_array( $rdatePart ) &&
2971 2970
             isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2972
-          if( $utctime )
2971
+            if( $utctime )
2973 2972
             unset( $rdatePart[0]['tz'] );
2974
-          $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2975
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
2973
+            $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2974
+            if( $utctime || !empty( $theRdate['params']['TZID'] ))
2976 2975
             $formatted = str_replace( 'Z', '', $formatted);
2977
-          if( 0 < $rpix ) {
2976
+            if( 0 < $rpix ) {
2978 2977
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2979
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2978
+                if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2980 2979
             }
2981 2980
             else
2982
-              $formatted = str_replace( 'Z', '', $formatted );
2983
-          }
2984
-          $contentPart .= $formatted;
2985
-          $contentPart .= '/';
2986
-          $cnt2 = count( $rdatePart[1]);
2987
-          if( array_key_exists( 'year', $rdatePart[1] )) {
2981
+                $formatted = str_replace( 'Z', '', $formatted );
2982
+            }
2983
+            $contentPart .= $formatted;
2984
+            $contentPart .= '/';
2985
+            $cnt2 = count( $rdatePart[1]);
2986
+            if( array_key_exists( 'year', $rdatePart[1] )) {
2988 2987
             if( array_key_exists( 'hour', $rdatePart[1] ))
2989
-              $cnt2 = 7;                                      // date-time
2988
+                $cnt2 = 7;                                      // date-time
2990 2989
             else
2991
-              $cnt2 = 3;                                      // date
2992
-          }
2993
-          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
2990
+                $cnt2 = 3;                                      // date
2991
+            }
2992
+            elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
2994 2993
             $cnt2 = 5;
2995
-          if(( 7 == $cnt2 )   &&    // period=  -> date-time
2994
+            if(( 7 == $cnt2 )   &&    // period=  -> date-time
2996 2995
               isset( $rdatePart[1]['year'] )  &&
2997 2996
               isset( $rdatePart[1]['month'] ) &&
2998 2997
               isset( $rdatePart[1]['day'] )) {
2999 2998
             if( $utctime )
3000
-              unset( $rdatePart[1]['tz'] );
2999
+                unset( $rdatePart[1]['tz'] );
3001 3000
             $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3002 3001
             if( $utctime || !empty( $theRdate['params']['TZID'] ))
3003
-              $formatted = str_replace( 'Z', '', $formatted);
3002
+                $formatted = str_replace( 'Z', '', $formatted);
3004 3003
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3005
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3004
+                if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3006 3005
             }
3007 3006
             else
3008
-              $formatted = str_replace( 'Z', '', $formatted );
3009
-           $contentPart .= $formatted;
3010
-          }
3011
-          else {                                  // period=  -> dur-time
3007
+                $formatted = str_replace( 'Z', '', $formatted );
3008
+            $contentPart .= $formatted;
3009
+            }
3010
+            else {                                  // period=  -> dur-time
3012 3011
             $contentPart .= $this->_format_duration( $rdatePart[1] );
3013
-          }
3012
+            }
3014 3013
         } // PERIOD end
3015 3014
         else { // SINGLE date start
3016
-          if( $utctime )
3015
+            if( $utctime )
3017 3016
             unset( $rdatePart['tz'] );
3018
-          $formatted = $this->_format_date_time( $rdatePart);
3019
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
3017
+            $formatted = $this->_format_date_time( $rdatePart);
3018
+            if( $utctime || !empty( $theRdate['params']['TZID'] ))
3020 3019
             $formatted = str_replace( 'Z', '', $formatted);
3021
-          if( !$utctime && ( 0 < $rpix )) {
3020
+            if( !$utctime && ( 0 < $rpix )) {
3022 3021
             if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3023
-              if( 'Z' != substr( $formatted, -1 ))
3022
+                if( 'Z' != substr( $formatted, -1 ))
3024 3023
                 $formatted .= 'Z';
3025 3024
             }
3026 3025
             else
3027
-              $formatted = str_replace( 'Z', '', $formatted );
3028
-          }
3029
-          $contentPart .= $formatted;
3026
+                $formatted = str_replace( 'Z', '', $formatted );
3027
+            }
3028
+            $contentPart .= $formatted;
3030 3029
         }
3031 3030
         $content .= $contentPart;
3032 3031
         if( $rno < $cnt )
3033
-          $content .= ',';
3032
+            $content .= ',';
3034 3033
         $rno++;
3035
-      }
3036
-      $output    .= $this->_createElement( 'RDATE', $attributes, $content );
3034
+        }
3035
+        $output    .= $this->_createElement( 'RDATE', $attributes, $content );
3037 3036
     }
3038 3037
     return $output;
3039
-  }
3038
+    }
3040 3039
 /**
3041
- * set calendar component property rdate
3042
- *
3043
- * @author Kjell-Inge Gustafsson <[email protected]>
3044
- * @since 2.5.1 - 2008-11-07
3045
- * @param array $rdates
3046
- * @param array $params, optional
3047
- * @param integer $index, optional
3048
- * @return bool
3049
- */
3050
-  function setRdate( $rdates, $params=FALSE, $index=FALSE ) {
3040
+     * set calendar component property rdate
3041
+     *
3042
+     * @author Kjell-Inge Gustafsson <[email protected]>
3043
+     * @since 2.5.1 - 2008-11-07
3044
+     * @param array $rdates
3045
+     * @param array $params, optional
3046
+     * @param integer $index, optional
3047
+     * @return bool
3048
+     */
3049
+    function setRdate( $rdates, $params=FALSE, $index=FALSE ) {
3051 3050
     if( empty( $rdates )) {
3052
-      if( $this->getConfig( 'allowEmpty' )) {
3051
+        if( $this->getConfig( 'allowEmpty' )) {
3053 3052
         $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3054 3053
         return TRUE;
3055
-      }
3056
-      else
3054
+        }
3055
+        else
3057 3056
         return FALSE;
3058 3057
     }
3059 3058
     $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3060 3059
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3061
-      unset( $input['params']['TZID'] );
3062
-      $input['params']['VALUE'] = 'DATE-TIME';
3060
+        unset( $input['params']['TZID'] );
3061
+        $input['params']['VALUE'] = 'DATE-TIME';
3063 3062
     }
3064 3063
             /*  check if PERIOD, if not set */
3065 3064
     if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) &&
@@ -3069,73 +3068,73 @@  discard block
 block discarded – undo
3069 3068
                                       $this->_isArrayDate( $rdates[0][0] ))) ||
3070 3069
                                     ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3071 3070
      ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3072
-      $input['params']['VALUE'] = 'PERIOD';
3071
+        $input['params']['VALUE'] = 'PERIOD';
3073 3072
             /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3074 3073
     $date  = reset( $rdates );
3075 3074
     if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3076
-      $date  = reset( $date );
3075
+        $date  = reset( $date );
3077 3076
     $this->_chkdatecfg( $date, $parno, $input['params'] );
3078 3077
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3079
-      unset( $input['params']['TZID'] );
3078
+        unset( $input['params']['TZID'] );
3080 3079
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3081 3080
     foreach( $rdates as $rpix => $theRdate ) {
3082
-      $inputa = null;
3083
-      if( is_array( $theRdate )) {
3081
+        $inputa = null;
3082
+        if( is_array( $theRdate )) {
3084 3083
         if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3085
-          foreach( $theRdate as $rix => $rPeriod ) {
3084
+            foreach( $theRdate as $rix => $rPeriod ) {
3086 3085
             if( is_array( $rPeriod )) {
3087
-              if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3086
+                if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3088 3087
                 $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3089
-              elseif( $this->_isArrayDate( $rPeriod ))
3088
+                elseif( $this->_isArrayDate( $rPeriod ))
3090 3089
                 $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3091
-              elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3090
+                elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3092 3091
                 $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3093
-              else                                               // array format duration
3092
+                else                                               // array format duration
3094 3093
                 $inputab  = $this->_duration_array( $rPeriod );
3095 3094
             }
3096 3095
             elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3097 3096
                    ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3098
-              if( 'P' != $rPeriod{0} )
3097
+                if( 'P' != $rPeriod{0} )
3099 3098
                 $rPeriod  = substr( $rPeriod, 1 );
3100
-              $inputab    = $this->_duration_string( $rPeriod );
3099
+                $inputab    = $this->_duration_string( $rPeriod );
3101 3100
             }
3102 3101
             elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3103
-              $inputab    = $this->_date_time_string( $rPeriod, $parno );
3102
+                $inputab    = $this->_date_time_string( $rPeriod, $parno );
3104 3103
             if(  isset( $input['params']['TZID'] ) ||
3105 3104
                ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3106 3105
                ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3107 3106
                ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3108
-              unset( $inputab['tz'] );
3107
+                unset( $inputab['tz'] );
3109 3108
             $inputa[]     = $inputab;
3110
-          }
3109
+            }
3111 3110
         } // PERIOD end
3112 3111
         elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3113
-          $inputa = $this->_timestamp2date( $theRdate, $parno );
3112
+            $inputa = $this->_timestamp2date( $theRdate, $parno );
3114 3113
         else                                                     // date[-time]
3115
-          $inputa = $this->_date_time_array( $theRdate, $parno );
3116
-      }
3117
-      elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3114
+            $inputa = $this->_date_time_array( $theRdate, $parno );
3115
+        }
3116
+        elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3118 3117
         $inputa       = $this->_date_time_string( $theRdate, $parno );
3119
-      if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3118
+        if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3120 3119
         if( 3 == $parno )
3121
-          unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3120
+            unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3122 3121
         elseif( isset( $inputa['tz'] ))
3123
-          $inputa['tz'] = (string) $inputa['tz'];
3122
+            $inputa['tz'] = (string) $inputa['tz'];
3124 3123
         if(  isset( $input['params']['TZID'] ) ||
3125 3124
            ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3126 3125
            ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3127 3126
            ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3128
-          unset( $inputa['tz'] );
3129
-      }
3130
-      $input['value'][] = $inputa;
3127
+            unset( $inputa['tz'] );
3128
+        }
3129
+        $input['value'][] = $inputa;
3131 3130
     }
3132 3131
     if( 3 == $parno ) {
3133
-      $input['params']['VALUE'] = 'DATE';
3134
-      unset( $input['params']['TZID'] );
3132
+        $input['params']['VALUE'] = 'DATE';
3133
+        unset( $input['params']['TZID'] );
3135 3134
     }
3136 3135
     $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index );
3137 3136
     return TRUE;
3138
-  }
3137
+    }
3139 3138
 /*********************************************************************************/
3140 3139
 /**
3141 3140
  * Property Name: RECURRENCE-ID
@@ -3147,40 +3146,40 @@  discard block
 block discarded – undo
3147 3146
  * @since 2.4.8 - 2008-10-21
3148 3147
  * @return string
3149 3148
  */
3150
-  function createRecurrenceid() {
3149
+    function createRecurrenceid() {
3151 3150
     if( empty( $this->recurrenceid )) return FALSE;
3152 3151
     if( empty( $this->recurrenceid['value'] ))
3153
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3152
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3154 3153
     $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3155 3154
     $attributes = $this->_createParams( $this->recurrenceid['params'] );
3156 3155
     return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
3157
-  }
3156
+    }
3158 3157
 /**
3159
- * set calendar component property recurrence-id
3160
- *
3161
- * @author Kjell-Inge Gustafsson <[email protected]>
3162
- * @since 2.4.8 - 2008-10-23
3163
- * @param mixed $year
3164
- * @param mixed $month optional
3165
- * @param int $day optional
3166
- * @param int $hour optional
3167
- * @param int $min optional
3168
- * @param int $sec optional
3169
- * @param array $params optional
3170
- * @return bool
3171
- */
3172
-  function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
3158
+     * set calendar component property recurrence-id
3159
+     *
3160
+     * @author Kjell-Inge Gustafsson <[email protected]>
3161
+     * @since 2.4.8 - 2008-10-23
3162
+     * @param mixed $year
3163
+     * @param mixed $month optional
3164
+     * @param int $day optional
3165
+     * @param int $hour optional
3166
+     * @param int $min optional
3167
+     * @param int $sec optional
3168
+     * @param array $params optional
3169
+     * @return bool
3170
+     */
3171
+    function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
3173 3172
     if( empty( $year )) {
3174
-      if( $this->getConfig( 'allowEmpty' )) {
3173
+        if( $this->getConfig( 'allowEmpty' )) {
3175 3174
         $this->recurrenceid = array( 'value' => null, 'params' => null );
3176 3175
         return TRUE;
3177
-      }
3178
-      else
3176
+        }
3177
+        else
3179 3178
         return FALSE;
3180 3179
     }
3181 3180
     $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3182 3181
     return TRUE;
3183
-  }
3182
+    }
3184 3183
 /*********************************************************************************/
3185 3184
 /**
3186 3185
  * Property Name: RELATED-TO
@@ -3192,40 +3191,40 @@  discard block
 block discarded – undo
3192 3191
  * @since 2.4.8 - 2008-10-23
3193 3192
  * @return string
3194 3193
  */
3195
-  function createRelatedTo() {
3194
+    function createRelatedTo() {
3196 3195
     if( empty( $this->relatedto )) return FALSE;
3197 3196
     $output = null;
3198 3197
     foreach( $this->relatedto as $relation ) {
3199
-      if( empty( $relation['value'] )) {
3198
+        if( empty( $relation['value'] )) {
3200 3199
         if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3201 3200
         continue;
3202
-      }
3203
-      $attributes = $this->_createParams( $relation['params'] );
3204
-      $content    = ( 'xcal' != $this->format ) ? '<' : '';
3205
-      $content   .= $this->_strrep( $relation['value'] );
3206
-      $content   .= ( 'xcal' != $this->format ) ? '>' : '';
3207
-      $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
3201
+        }
3202
+        $attributes = $this->_createParams( $relation['params'] );
3203
+        $content    = ( 'xcal' != $this->format ) ? '<' : '';
3204
+        $content   .= $this->_strrep( $relation['value'] );
3205
+        $content   .= ( 'xcal' != $this->format ) ? '>' : '';
3206
+        $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
3208 3207
     }
3209 3208
     return $output;
3210
-  }
3209
+    }
3211 3210
 /**
3212
- * set calendar component property related-to
3213
- *
3214
- * @author Kjell-Inge Gustafsson <[email protected]>
3215
- * @since 2.5.1 - 2008-11-07
3216
- * @param float $relid
3217
- * @param array $params, optional
3218
- * @param index $index, optional
3219
- * @return bool
3220
- */
3221
-  function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3211
+     * set calendar component property related-to
3212
+     *
3213
+     * @author Kjell-Inge Gustafsson <[email protected]>
3214
+     * @since 2.5.1 - 2008-11-07
3215
+     * @param float $relid
3216
+     * @param array $params, optional
3217
+     * @param index $index, optional
3218
+     * @return bool
3219
+     */
3220
+    function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3222 3221
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3223 3222
     if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3224
-      $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3223
+        $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3225 3224
     $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3226 3225
     $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3227 3226
     return TRUE;
3228
-  }
3227
+    }
3229 3228
 /*********************************************************************************/
3230 3229
 /**
3231 3230
  * Property Name: REPEAT
@@ -3237,27 +3236,27 @@  discard block
 block discarded – undo
3237 3236
  * @since 2.4.8 - 2008-10-21
3238 3237
  * @return string
3239 3238
  */
3240
-  function createRepeat() {
3239
+    function createRepeat() {
3241 3240
     if( empty( $this->repeat )) return FALSE;
3242 3241
     if( empty( $this->repeat['value'] ))
3243
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3242
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3244 3243
     $attributes = $this->_createParams( $this->repeat['params'] );
3245 3244
     return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3246
-  }
3245
+    }
3247 3246
 /**
3248
- * set calendar component property transp
3249
- *
3250
- * @author Kjell-Inge Gustafsson <[email protected]>
3251
- * @since 2.4.8 - 2008-11-04
3252
- * @param string $value
3253
- * @param array $params optional
3254
- * @return void
3255
- */
3256
-  function setRepeat( $value, $params=FALSE ) {
3247
+     * set calendar component property transp
3248
+     *
3249
+     * @author Kjell-Inge Gustafsson <[email protected]>
3250
+     * @since 2.4.8 - 2008-11-04
3251
+     * @param string $value
3252
+     * @param array $params optional
3253
+     * @return void
3254
+     */
3255
+    function setRepeat( $value, $params=FALSE ) {
3257 3256
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3258 3257
     $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3259 3258
     return TRUE;
3260
-  }
3259
+    }
3261 3260
 /*********************************************************************************/
3262 3261
 /**
3263 3262
  * Property Name: REQUEST-STATUS
@@ -3268,43 +3267,43 @@  discard block
 block discarded – undo
3268 3267
  * @since 2.4.8 - 2008-10-23
3269 3268
  * @return string
3270 3269
  */
3271
-  function createRequestStatus() {
3270
+    function createRequestStatus() {
3272 3271
     if( empty( $this->requeststatus )) return FALSE;
3273 3272
     $output = null;
3274 3273
     foreach( $this->requeststatus as $rstat ) {
3275
-      if( empty( $rstat['value']['statcode'] )) {
3274
+        if( empty( $rstat['value']['statcode'] )) {
3276 3275
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3277 3276
         continue;
3278
-      }
3279
-      $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3280
-      $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3281
-      $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3282
-      if( isset( $rstat['value']['extdata'] ))
3277
+        }
3278
+        $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3279
+        $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3280
+        $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3281
+        if( isset( $rstat['value']['extdata'] ))
3283 3282
         $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3284
-      $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3283
+        $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3285 3284
     }
3286 3285
     return $output;
3287
-  }
3286
+    }
3288 3287
 /**
3289
- * set calendar component property request-status
3290
- *
3291
- * @author Kjell-Inge Gustafsson <[email protected]>
3292
- * @since 2.5.1 - 2008-11-05
3293
- * @param float $statcode
3294
- * @param string $text
3295
- * @param string $extdata, optional
3296
- * @param array $params, optional
3297
- * @param integer $index, optional
3298
- * @return bool
3299
- */
3300
-  function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3288
+     * set calendar component property request-status
3289
+     *
3290
+     * @author Kjell-Inge Gustafsson <[email protected]>
3291
+     * @since 2.5.1 - 2008-11-05
3292
+     * @param float $statcode
3293
+     * @param string $text
3294
+     * @param string $extdata, optional
3295
+     * @param array $params, optional
3296
+     * @param integer $index, optional
3297
+     * @return bool
3298
+     */
3299
+    function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3301 3300
     if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3302 3301
     $input              = array( 'statcode' => $statcode, 'text' => $text );
3303 3302
     if( $extdata )
3304
-      $input['extdata'] = $extdata;
3303
+        $input['extdata'] = $extdata;
3305 3304
     $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3306 3305
     return TRUE;
3307
-  }
3306
+    }
3308 3307
 /*********************************************************************************/
3309 3308
 /**
3310 3309
  * Property Name: RESOURCES
@@ -3316,41 +3315,41 @@  discard block
 block discarded – undo
3316 3315
  * @since 2.4.8 - 2008-10-23
3317 3316
  * @return string
3318 3317
  */
3319
-  function createResources() {
3318
+    function createResources() {
3320 3319
     if( empty( $this->resources )) return FALSE;
3321 3320
     $output = null;
3322 3321
     foreach( $this->resources as $resource ) {
3323
-      if( empty( $resource['value'] )) {
3322
+        if( empty( $resource['value'] )) {
3324 3323
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3325 3324
         continue;
3326
-      }
3327
-      $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3328
-      if( is_array( $resource['value'] )) {
3325
+        }
3326
+        $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3327
+        if( is_array( $resource['value'] )) {
3329 3328
         foreach( $resource['value'] as $rix => $resourcePart )
3330
-          $resource['value'][$rix] = $this->_strrep( $resourcePart );
3329
+            $resource['value'][$rix] = $this->_strrep( $resourcePart );
3331 3330
         $content   = implode( ',', $resource['value'] );
3332
-      }
3333
-      else
3331
+        }
3332
+        else
3334 3333
         $content   = $this->_strrep( $resource['value'] );
3335
-      $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3334
+        $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3336 3335
     }
3337 3336
     return $output;
3338
-  }
3337
+    }
3339 3338
 /**
3340
- * set calendar component property recources
3341
- *
3342
- * @author Kjell-Inge Gustafsson <[email protected]>
3343
- * @since 2.5.1 - 2008-11-05
3344
- * @param mixed $value
3345
- * @param array $params, optional
3346
- * @param integer $index, optional
3347
- * @return bool
3348
- */
3349
-  function setResources( $value, $params=FALSE, $index=FALSE ) {
3339
+     * set calendar component property recources
3340
+     *
3341
+     * @author Kjell-Inge Gustafsson <[email protected]>
3342
+     * @since 2.5.1 - 2008-11-05
3343
+     * @param mixed $value
3344
+     * @param array $params, optional
3345
+     * @param integer $index, optional
3346
+     * @return bool
3347
+     */
3348
+    function setResources( $value, $params=FALSE, $index=FALSE ) {
3350 3349
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3351 3350
     $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3352 3351
     return TRUE;
3353
-  }
3352
+    }
3354 3353
 /*********************************************************************************/
3355 3354
 /**
3356 3355
  * Property Name: RRULE
@@ -3362,25 +3361,25 @@  discard block
 block discarded – undo
3362 3361
  * @since 2.4.8 - 2008-10-21
3363 3362
  * @return string
3364 3363
  */
3365
-  function createRrule() {
3364
+    function createRrule() {
3366 3365
     if( empty( $this->rrule )) return FALSE;
3367 3366
     return $this->_format_recur( 'RRULE', $this->rrule );
3368
-  }
3367
+    }
3369 3368
 /**
3370
- * set calendar component property rrule
3371
- *
3372
- * @author Kjell-Inge Gustafsson <[email protected]>
3373
- * @since 2.5.1 - 2008-11-05
3374
- * @param array $rruleset
3375
- * @param array $params, optional
3376
- * @param integer $index, optional
3377
- * @return void
3378
- */
3379
-  function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3369
+     * set calendar component property rrule
3370
+     *
3371
+     * @author Kjell-Inge Gustafsson <[email protected]>
3372
+     * @since 2.5.1 - 2008-11-05
3373
+     * @param array $rruleset
3374
+     * @param array $params, optional
3375
+     * @param integer $index, optional
3376
+     * @return void
3377
+     */
3378
+    function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380 3379
     if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3381 3380
     $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3382 3381
     return TRUE;
3383
-  }
3382
+    }
3384 3383
 /*********************************************************************************/
3385 3384
 /**
3386 3385
  * Property Name: SEQUENCE
@@ -3391,27 +3390,27 @@  discard block
 block discarded – undo
3391 3390
  * @since 0.9.7 - 2006-11-20
3392 3391
  * @return string
3393 3392
  */
3394
-  function createSequence() {
3393
+    function createSequence() {
3395 3394
     if( empty( $this->sequence )) return FALSE;
3396 3395
     if( empty( $this->sequence['value'] ))
3397
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3396
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3398 3397
     $attributes = $this->_createParams( $this->sequence['params'] );
3399 3398
     return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3400
-  }
3399
+    }
3401 3400
 /**
3402
- * set calendar component property sequence
3403
- * @author Kjell-Inge Gustafsson <[email protected]>
3404
- * @since 2.4.8 - 2008-11-04
3405
- * @param int $value optional
3406
- * @param array $params optional
3407
- * @return bool
3408
- */
3409
-  function setSequence( $value=FALSE, $params=FALSE ) {
3401
+     * set calendar component property sequence
3402
+     * @author Kjell-Inge Gustafsson <[email protected]>
3403
+     * @since 2.4.8 - 2008-11-04
3404
+     * @param int $value optional
3405
+     * @param array $params optional
3406
+     * @return bool
3407
+     */
3408
+    function setSequence( $value=FALSE, $params=FALSE ) {
3410 3409
     if( empty( $value ))
3411
-      $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3410
+        $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3412 3411
     $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3413 3412
     return TRUE;
3414
-  }
3413
+    }
3415 3414
 /*********************************************************************************/
3416 3415
 /**
3417 3416
  * Property Name: STATUS
@@ -3423,27 +3422,27 @@  discard block
 block discarded – undo
3423 3422
  * @since 2.4.8 - 2008-10-21
3424 3423
  * @return string
3425 3424
  */
3426
-  function createStatus() {
3425
+    function createStatus() {
3427 3426
     if( empty( $this->status )) return FALSE;
3428 3427
     if( empty( $this->status['value'] ))
3429
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3428
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3430 3429
     $attributes = $this->_createParams( $this->status['params'] );
3431 3430
     return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3432
-  }
3431
+    }
3433 3432
 /**
3434
- * set calendar component property status
3435
- *
3436
- * @author Kjell-Inge Gustafsson <[email protected]>
3437
- * @since 2.4.8 - 2008-11-04
3438
- * @param string $value
3439
- * @param array $params optional
3440
- * @return bool
3441
- */
3442
-  function setStatus( $value, $params=FALSE ) {
3433
+     * set calendar component property status
3434
+     *
3435
+     * @author Kjell-Inge Gustafsson <[email protected]>
3436
+     * @since 2.4.8 - 2008-11-04
3437
+     * @param string $value
3438
+     * @param array $params optional
3439
+     * @return bool
3440
+     */
3441
+    function setStatus( $value, $params=FALSE ) {
3443 3442
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3444 3443
     $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3445 3444
     return TRUE;
3446
-  }
3445
+    }
3447 3446
 /*********************************************************************************/
3448 3447
 /**
3449 3448
  * Property Name: SUMMARY
@@ -3455,28 +3454,28 @@  discard block
 block discarded – undo
3455 3454
  * @since 2.4.8 - 2008-10-21
3456 3455
  * @return string
3457 3456
  */
3458
-  function createSummary() {
3457
+    function createSummary() {
3459 3458
     if( empty( $this->summary )) return FALSE;
3460 3459
     if( empty( $this->summary['value'] ))
3461
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3460
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3462 3461
     $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3463 3462
     $content    = $this->_strrep( $this->summary['value'] );
3464 3463
     return $this->_createElement( 'SUMMARY', $attributes, $content );
3465
-  }
3464
+    }
3466 3465
 /**
3467
- * set calendar component property summary
3468
- *
3469
- * @author Kjell-Inge Gustafsson <[email protected]>
3470
- * @since 2.4.8 - 2008-11-04
3471
- * @param string $value
3472
- * @param string $params optional
3473
- * @return bool
3474
- */
3475
-  function setSummary( $value, $params=FALSE ) {
3466
+     * set calendar component property summary
3467
+     *
3468
+     * @author Kjell-Inge Gustafsson <[email protected]>
3469
+     * @since 2.4.8 - 2008-11-04
3470
+     * @param string $value
3471
+     * @param string $params optional
3472
+     * @return bool
3473
+     */
3474
+    function setSummary( $value, $params=FALSE ) {
3476 3475
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3477 3476
     $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3478 3477
     return TRUE;
3479
-  }
3478
+    }
3480 3479
 /*********************************************************************************/
3481 3480
 /**
3482 3481
  * Property Name: TRANSP
@@ -3488,27 +3487,27 @@  discard block
 block discarded – undo
3488 3487
  * @since 2.4.8 - 2008-10-21
3489 3488
  * @return string
3490 3489
  */
3491
-  function createTransp() {
3490
+    function createTransp() {
3492 3491
     if( empty( $this->transp )) return FALSE;
3493 3492
     if( empty( $this->transp['value'] ))
3494
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3493
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3495 3494
     $attributes = $this->_createParams( $this->transp['params'] );
3496 3495
     return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3497
-  }
3496
+    }
3498 3497
 /**
3499
- * set calendar component property transp
3500
- *
3501
- * @author Kjell-Inge Gustafsson <[email protected]>
3502
- * @since 2.4.8 - 2008-11-04
3503
- * @param string $value
3504
- * @param string $params optional
3505
- * @return bool
3506
- */
3507
-  function setTransp( $value, $params=FALSE ) {
3498
+     * set calendar component property transp
3499
+     *
3500
+     * @author Kjell-Inge Gustafsson <[email protected]>
3501
+     * @since 2.4.8 - 2008-11-04
3502
+     * @param string $value
3503
+     * @param string $params optional
3504
+     * @return bool
3505
+     */
3506
+    function setTransp( $value, $params=FALSE ) {
3508 3507
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3509 3508
     $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3510 3509
     return TRUE;
3511
-  }
3510
+    }
3512 3511
 /*********************************************************************************/
3513 3512
 /**
3514 3513
  * Property Name: TRIGGER
@@ -3520,126 +3519,126 @@  discard block
 block discarded – undo
3520 3519
  * @since 2.4.16 - 2008-10-21
3521 3520
  * @return string
3522 3521
  */
3523
-  function createTrigger() {
3522
+    function createTrigger() {
3524 3523
     if( empty( $this->trigger )) return FALSE;
3525 3524
     if( empty( $this->trigger['value'] ))
3526
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3525
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3527 3526
     $content = $attributes = null;
3528 3527
     if( isset( $this->trigger['value']['year'] )   &&
3529 3528
         isset( $this->trigger['value']['month'] )  &&
3530 3529
         isset( $this->trigger['value']['day'] ))
3531
-      $content      .= $this->_format_date_time( $this->trigger['value'] );
3530
+        $content      .= $this->_format_date_time( $this->trigger['value'] );
3532 3531
     else {
3533
-      if( TRUE !== $this->trigger['value']['relatedStart'] )
3532
+        if( TRUE !== $this->trigger['value']['relatedStart'] )
3534 3533
         $attributes .= $this->intAttrDelimiter.'RELATED=END';
3535
-      if( $this->trigger['value']['before'] )
3534
+        if( $this->trigger['value']['before'] )
3536 3535
         $content    .= '-';
3537
-      $content      .= $this->_format_duration( $this->trigger['value'] );
3536
+        $content      .= $this->_format_duration( $this->trigger['value'] );
3538 3537
     }
3539 3538
     $attributes     .= $this->_createParams( $this->trigger['params'] );
3540 3539
     return $this->_createElement( 'TRIGGER', $attributes, $content );
3541
-  }
3540
+    }
3542 3541
 /**
3543
- * set calendar component property trigger
3544
- *
3545
- * @author Kjell-Inge Gustafsson <[email protected]>
3546
- * @since 2.4.16 - 2008-11-04
3547
- * @param mixed $year
3548
- * @param mixed $month optional
3549
- * @param int $day optional
3550
- * @param int $week optional
3551
- * @param int $hour optional
3552
- * @param int $min optional
3553
- * @param int $sec optional
3554
- * @param bool $relatedStart optional
3555
- * @param bool $before optional
3556
- * @param array $params optional
3557
- * @return bool
3558
- */
3559
-  function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3542
+     * set calendar component property trigger
3543
+     *
3544
+     * @author Kjell-Inge Gustafsson <[email protected]>
3545
+     * @since 2.4.16 - 2008-11-04
3546
+     * @param mixed $year
3547
+     * @param mixed $month optional
3548
+     * @param int $day optional
3549
+     * @param int $week optional
3550
+     * @param int $hour optional
3551
+     * @param int $min optional
3552
+     * @param int $sec optional
3553
+     * @param bool $relatedStart optional
3554
+     * @param bool $before optional
3555
+     * @param array $params optional
3556
+     * @return bool
3557
+     */
3558
+    function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3560 3559
     if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3561
-      if( $this->getConfig( 'allowEmpty' )) {
3560
+        if( $this->getConfig( 'allowEmpty' )) {
3562 3561
         $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3563 3562
         return TRUE;
3564
-      }
3565
-      else
3563
+        }
3564
+        else
3566 3565
         return FALSE;
3567 3566
     if( $this->_isArrayTimestampDate( $year )) { // timestamp
3568
-      $params = $this->_setParams( $month );
3569
-      $date   = $this->_timestamp2date( $year, 7 );
3570
-      foreach( $date as $k => $v )
3567
+        $params = $this->_setParams( $month );
3568
+        $date   = $this->_timestamp2date( $year, 7 );
3569
+        foreach( $date as $k => $v )
3571 3570
         $$k = $v;
3572 3571
     }
3573 3572
     elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3574
-      $params = $this->_setParams( $month );
3575
-      if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3573
+        $params = $this->_setParams( $month );
3574
+        if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3576 3575
            array_key_exists( 'month', $year ) &&
3577 3576
            array_key_exists( 'day',   $year ))) {  // so this must be a duration
3578 3577
         if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3579
-          $relatedStart = FALSE;
3578
+            $relatedStart = FALSE;
3580 3579
         else
3581
-          $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
3580
+            $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
3582 3581
         $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3583
-      }
3584
-      $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
3585
-      $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null;
3586
-      $day   = ( array_key_exists( 'day',   $year )) ? $year['day']   : null;
3587
-      $week  = ( array_key_exists( 'week',  $year )) ? $year['week']  : null;
3588
-      $hour  = ( array_key_exists( 'hour',  $year )) ? $year['hour']  : 0; //null;
3589
-      $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3590
-      $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3591
-      $year  = $SSYY;
3582
+        }
3583
+        $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
3584
+        $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null;
3585
+        $day   = ( array_key_exists( 'day',   $year )) ? $year['day']   : null;
3586
+        $week  = ( array_key_exists( 'week',  $year )) ? $year['week']  : null;
3587
+        $hour  = ( array_key_exists( 'hour',  $year )) ? $year['hour']  : 0; //null;
3588
+        $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3589
+        $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3590
+        $year  = $SSYY;
3592 3591
     }
3593 3592
     elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3594
-      $params = $this->_setParams( $month );
3595
-      if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3593
+        $params = $this->_setParams( $month );
3594
+        if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3596 3595
         $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3597 3596
         $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3598 3597
         if(     'P'  != $year{0} )
3599
-          $year       = substr( $year, 1 );
3598
+            $year       = substr( $year, 1 );
3600 3599
         $date         = $this->_duration_string( $year);
3601
-      }
3602
-      else   // date
3600
+        }
3601
+        else   // date
3603 3602
         $date    = $this->_date_time_string( $year, 7 );
3604
-      unset( $year, $month, $day );
3605
-      foreach( $date as $k => $v )
3603
+        unset( $year, $month, $day );
3604
+        foreach( $date as $k => $v )
3606 3605
         $$k = $v;
3607 3606
     }
3608 3607
     else // single values in function input parameters
3609
-      $params = $this->_setParams( $params );
3608
+        $params = $this->_setParams( $params );
3610 3609
     if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3611
-      $params['VALUE'] = 'DATE-TIME';
3612
-      $hour = ( $hour ) ? $hour : 0;
3613
-      $min  = ( $min  ) ? $min  : 0;
3614
-      $sec  = ( $sec  ) ? $sec  : 0;
3615
-      $this->trigger = array( 'params' => $params );
3616
-      $this->trigger['value'] = array( 'year'  => $year
3617
-                                     , 'month' => $month
3618
-                                     , 'day'   => $day
3619
-                                     , 'hour'  => $hour
3620
-                                     , 'min'   => $min
3621
-                                     , 'sec'   => $sec
3622
-                                     , 'tz'    => 'Z' );
3623
-      return TRUE;
3610
+        $params['VALUE'] = 'DATE-TIME';
3611
+        $hour = ( $hour ) ? $hour : 0;
3612
+        $min  = ( $min  ) ? $min  : 0;
3613
+        $sec  = ( $sec  ) ? $sec  : 0;
3614
+        $this->trigger = array( 'params' => $params );
3615
+        $this->trigger['value'] = array( 'year'  => $year
3616
+                                        , 'month' => $month
3617
+                                        , 'day'   => $day
3618
+                                        , 'hour'  => $hour
3619
+                                        , 'min'   => $min
3620
+                                        , 'sec'   => $sec
3621
+                                        , 'tz'    => 'Z' );
3622
+        return TRUE;
3624 3623
     }
3625 3624
     elseif(( empty( $year ) && empty( $month )) &&    // duration
3626 3625
            (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3627
-      unset( $params['RELATED'] ); // set at output creation (END only)
3628
-      unset( $params['VALUE'] );   // 'DURATION' default
3629
-      $this->trigger = array( 'params' => $params );
3630
-      $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE;
3631
-      $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3632
-      $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3633
-                                      , 'before'       => $before );
3634
-      if( !empty( $week )) $this->trigger['value']['week'] = $week;
3635
-      if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3636
-      if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3637
-      if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3638
-      if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
3639
-      return TRUE;
3626
+        unset( $params['RELATED'] ); // set at output creation (END only)
3627
+        unset( $params['VALUE'] );   // 'DURATION' default
3628
+        $this->trigger = array( 'params' => $params );
3629
+        $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE;
3630
+        $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3631
+        $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3632
+                                        , 'before'       => $before );
3633
+        if( !empty( $week )) $this->trigger['value']['week'] = $week;
3634
+        if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3635
+        if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3636
+        if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3637
+        if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
3638
+        return TRUE;
3640 3639
     }
3641 3640
     return FALSE;
3642
-  }
3641
+    }
3643 3642
 /*********************************************************************************/
3644 3643
 /**
3645 3644
  * Property Name: TZID
@@ -3651,27 +3650,27 @@  discard block
 block discarded – undo
3651 3650
  * @since 2.4.8 - 2008-10-21
3652 3651
  * @return string
3653 3652
  */
3654
-  function createTzid() {
3653
+    function createTzid() {
3655 3654
     if( empty( $this->tzid )) return FALSE;
3656 3655
     if( empty( $this->tzid['value'] ))
3657
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
3656
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
3658 3657
     $attributes = $this->_createParams( $this->tzid['params'] );
3659 3658
     return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3660
-  }
3659
+    }
3661 3660
 /**
3662
- * set calendar component property tzid
3663
- *
3664
- * @author Kjell-Inge Gustafsson <[email protected]>
3665
- * @since 2.4.8 - 2008-11-04
3666
- * @param string $value
3667
- * @param array $params optional
3668
- * @return bool
3669
- */
3670
-  function setTzid( $value, $params=FALSE ) {
3661
+     * set calendar component property tzid
3662
+     *
3663
+     * @author Kjell-Inge Gustafsson <[email protected]>
3664
+     * @since 2.4.8 - 2008-11-04
3665
+     * @param string $value
3666
+     * @param array $params optional
3667
+     * @return bool
3668
+     */
3669
+    function setTzid( $value, $params=FALSE ) {
3671 3670
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3672 3671
     $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3673 3672
     return TRUE;
3674
-  }
3673
+    }
3675 3674
 /*********************************************************************************/
3676 3675
 /**
3677 3676
  * .. .
@@ -3684,33 +3683,33 @@  discard block
 block discarded – undo
3684 3683
  * @since 2.4.8 - 2008-10-21
3685 3684
  * @return string
3686 3685
  */
3687
-  function createTzname() {
3686
+    function createTzname() {
3688 3687
     if( empty( $this->tzname )) return FALSE;
3689 3688
     $output = null;
3690 3689
     foreach( $this->tzname as $theName ) {
3691
-      if( !empty( $theName['value'] )) {
3690
+        if( !empty( $theName['value'] )) {
3692 3691
         $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3693 3692
         $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
3694
-      }
3695
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3693
+        }
3694
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3696 3695
     }
3697 3696
     return $output;
3698
-  }
3697
+    }
3699 3698
 /**
3700
- * set calendar component property tzname
3701
- *
3702
- * @author Kjell-Inge Gustafsson <[email protected]>
3703
- * @since 2.5.1 - 2008-11-05
3704
- * @param string $value
3705
- * @param string $params, optional
3706
- * @param integer $index, optional
3707
- * @return bool
3708
- */
3709
-  function setTzname( $value, $params=FALSE, $index=FALSE ) {
3699
+     * set calendar component property tzname
3700
+     *
3701
+     * @author Kjell-Inge Gustafsson <[email protected]>
3702
+     * @since 2.5.1 - 2008-11-05
3703
+     * @param string $value
3704
+     * @param string $params, optional
3705
+     * @param integer $index, optional
3706
+     * @return bool
3707
+     */
3708
+    function setTzname( $value, $params=FALSE, $index=FALSE ) {
3710 3709
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3711 3710
     $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3712 3711
     return TRUE;
3713
-  }
3712
+    }
3714 3713
 /*********************************************************************************/
3715 3714
 /**
3716 3715
  * Property Name: TZOFFSETFROM
@@ -3722,27 +3721,27 @@  discard block
 block discarded – undo
3722 3721
  * @since 2.4.8 - 2008-10-21
3723 3722
  * @return string
3724 3723
  */
3725
-  function createTzoffsetfrom() {
3724
+    function createTzoffsetfrom() {
3726 3725
     if( empty( $this->tzoffsetfrom )) return FALSE;
3727 3726
     if( empty( $this->tzoffsetfrom['value'] ))
3728
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
3727
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
3729 3728
     $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3730 3729
     return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3731
-  }
3730
+    }
3732 3731
 /**
3733
- * set calendar component property tzoffsetfrom
3734
- *
3735
- * @author Kjell-Inge Gustafsson <[email protected]>
3736
- * @since 2.4.8 - 2008-11-04
3737
- * @param string $value
3738
- * @param string $params optional
3739
- * @return bool
3740
- */
3741
-  function setTzoffsetfrom( $value, $params=FALSE ) {
3732
+     * set calendar component property tzoffsetfrom
3733
+     *
3734
+     * @author Kjell-Inge Gustafsson <[email protected]>
3735
+     * @since 2.4.8 - 2008-11-04
3736
+     * @param string $value
3737
+     * @param string $params optional
3738
+     * @return bool
3739
+     */
3740
+    function setTzoffsetfrom( $value, $params=FALSE ) {
3742 3741
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3743 3742
     $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3744 3743
     return TRUE;
3745
-  }
3744
+    }
3746 3745
 /*********************************************************************************/
3747 3746
 /**
3748 3747
  * Property Name: TZOFFSETTO
@@ -3754,27 +3753,27 @@  discard block
 block discarded – undo
3754 3753
  * @since 2.4.8 - 2008-10-21
3755 3754
  * @return string
3756 3755
  */
3757
-  function createTzoffsetto() {
3756
+    function createTzoffsetto() {
3758 3757
     if( empty( $this->tzoffsetto )) return FALSE;
3759 3758
     if( empty( $this->tzoffsetto['value'] ))
3760
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
3759
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
3761 3760
     $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3762 3761
     return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3763
-  }
3762
+    }
3764 3763
 /**
3765
- * set calendar component property tzoffsetto
3766
- *
3767
- * @author Kjell-Inge Gustafsson <[email protected]>
3768
- * @since 2.4.8 - 2008-11-04
3769
- * @param string $value
3770
- * @param string $params optional
3771
- * @return bool
3772
- */
3773
-  function setTzoffsetto( $value, $params=FALSE ) {
3764
+     * set calendar component property tzoffsetto
3765
+     *
3766
+     * @author Kjell-Inge Gustafsson <[email protected]>
3767
+     * @since 2.4.8 - 2008-11-04
3768
+     * @param string $value
3769
+     * @param string $params optional
3770
+     * @return bool
3771
+     */
3772
+    function setTzoffsetto( $value, $params=FALSE ) {
3774 3773
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3775 3774
     $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3776 3775
     return TRUE;
3777
-  }
3776
+    }
3778 3777
 /*********************************************************************************/
3779 3778
 /**
3780 3779
  * Property Name: TZURL
@@ -3786,27 +3785,27 @@  discard block
 block discarded – undo
3786 3785
  * @since 2.4.8 - 2008-10-21
3787 3786
  * @return string
3788 3787
  */
3789
-  function createTzurl() {
3788
+    function createTzurl() {
3790 3789
     if( empty( $this->tzurl )) return FALSE;
3791 3790
     if( empty( $this->tzurl['value'] ))
3792
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
3791
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
3793 3792
     $attributes = $this->_createParams( $this->tzurl['params'] );
3794 3793
     return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3795
-  }
3794
+    }
3796 3795
 /**
3797
- * set calendar component property tzurl
3798
- *
3799
- * @author Kjell-Inge Gustafsson <[email protected]>
3800
- * @since 2.4.8 - 2008-11-04
3801
- * @param string $value
3802
- * @param string $params optional
3803
- * @return boll
3804
- */
3805
-  function setTzurl( $value, $params=FALSE ) {
3796
+     * set calendar component property tzurl
3797
+     *
3798
+     * @author Kjell-Inge Gustafsson <[email protected]>
3799
+     * @since 2.4.8 - 2008-11-04
3800
+     * @param string $value
3801
+     * @param string $params optional
3802
+     * @return boll
3803
+     */
3804
+    function setTzurl( $value, $params=FALSE ) {
3806 3805
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3807 3806
     $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3808 3807
     return TRUE;
3809
-  }
3808
+    }
3810 3809
 /*********************************************************************************/
3811 3810
 /**
3812 3811
  * Property Name: UID
@@ -3818,20 +3817,20 @@  discard block
 block discarded – undo
3818 3817
  * @since 0.9.7 - 2006-11-20
3819 3818
  * @return string
3820 3819
  */
3821
-  function createUid() {
3820
+    function createUid() {
3822 3821
     if( 0 >= count( $this->uid ))
3823
-      $this->_makeuid();
3822
+        $this->_makeuid();
3824 3823
     $attributes = $this->_createParams( $this->uid['params'] );
3825 3824
     return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3826
-  }
3825
+    }
3827 3826
 /**
3828
- * create an unique id for this calendar component object instance
3829
- *
3830
- * @author Kjell-Inge Gustafsson <[email protected]>
3831
- * @since 2.2.7 - 2007-09-04
3832
- * @return void
3833
- */
3834
-  function _makeUid() {
3827
+     * create an unique id for this calendar component object instance
3828
+     *
3829
+     * @author Kjell-Inge Gustafsson <[email protected]>
3830
+     * @since 2.2.7 - 2007-09-04
3831
+     * @return void
3832
+     */
3833
+    function _makeUid() {
3835 3834
     $date   = date('Ymd\THisT');
3836 3835
     $unique = substr(microtime(), 2, 4);
3837 3836
     $base   = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890';
@@ -3840,24 +3839,24 @@  discard block
 block discarded – undo
3840 3839
     $length = 6;
3841 3840
     $str    = null;
3842 3841
     for( $p = 0; $p < $length; $p++ )
3843
-      $unique .= $base{mt_rand( $start, $end )};
3842
+        $unique .= $base{mt_rand( $start, $end )};
3844 3843
     $this->uid = array( 'params' => null );
3845 3844
     $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3846
-  }
3845
+    }
3847 3846
 /**
3848
- * set calendar component property uid
3849
- *
3850
- * @author Kjell-Inge Gustafsson <[email protected]>
3851
- * @since 2.4.8 - 2008-11-04
3852
- * @param string $value
3853
- * @param string $params optional
3854
- * @return bool
3855
- */
3856
-  function setUid( $value, $params=FALSE ) {
3847
+     * set calendar component property uid
3848
+     *
3849
+     * @author Kjell-Inge Gustafsson <[email protected]>
3850
+     * @since 2.4.8 - 2008-11-04
3851
+     * @param string $value
3852
+     * @param string $params optional
3853
+     * @return bool
3854
+     */
3855
+    function setUid( $value, $params=FALSE ) {
3857 3856
     if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
3858 3857
     $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3859 3858
     return TRUE;
3860
-  }
3859
+    }
3861 3860
 /*********************************************************************************/
3862 3861
 /**
3863 3862
  * Property Name: URL
@@ -3869,27 +3868,27 @@  discard block
 block discarded – undo
3869 3868
  * @since 2.4.8 - 2008-10-21
3870 3869
  * @return string
3871 3870
  */
3872
-  function createUrl() {
3871
+    function createUrl() {
3873 3872
     if( empty( $this->url )) return FALSE;
3874 3873
     if( empty( $this->url['value'] ))
3875
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
3874
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
3876 3875
     $attributes = $this->_createParams( $this->url['params'] );
3877 3876
     return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3878
-  }
3877
+    }
3879 3878
 /**
3880
- * set calendar component property url
3881
- *
3882
- * @author Kjell-Inge Gustafsson <[email protected]>
3883
- * @since 2.4.8 - 2008-11-04
3884
- * @param string $value
3885
- * @param string $params optional
3886
- * @return bool
3887
- */
3888
-  function setUrl( $value, $params=FALSE ) {
3879
+     * set calendar component property url
3880
+     *
3881
+     * @author Kjell-Inge Gustafsson <[email protected]>
3882
+     * @since 2.4.8 - 2008-11-04
3883
+     * @param string $value
3884
+     * @param string $params optional
3885
+     * @return bool
3886
+     */
3887
+    function setUrl( $value, $params=FALSE ) {
3889 3888
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3890 3889
     $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3891 3890
     return TRUE;
3892
-  }
3891
+    }
3893 3892
 /*********************************************************************************/
3894 3893
 /**
3895 3894
  * Property Name: x-prop
@@ -3901,37 +3900,37 @@  discard block
 block discarded – undo
3901 3900
  * @since 2.4.11 - 2008-10-22
3902 3901
  * @return string
3903 3902
  */
3904
-  function createXprop() {
3903
+    function createXprop() {
3905 3904
     if( empty( $this->xprop )) return FALSE;
3906 3905
     $output = null;
3907 3906
     foreach( $this->xprop as $label => $xpropPart ) {
3908
-      if( empty( $xpropPart['value'] )) {
3907
+        if( empty( $xpropPart['value'] )) {
3909 3908
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
3910 3909
         continue;
3911
-      }
3912
-      $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3913
-      if( is_array( $xpropPart['value'] )) {
3910
+        }
3911
+        $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3912
+        if( is_array( $xpropPart['value'] )) {
3914 3913
         foreach( $xpropPart['value'] as $pix => $theXpart )
3915
-          $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
3914
+            $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
3916 3915
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
3917
-      }
3918
-      else
3916
+        }
3917
+        else
3919 3918
         $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3920
-      $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3919
+        $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3921 3920
     }
3922 3921
     return $output;
3923
-  }
3922
+    }
3924 3923
 /**
3925
- * set calendar component property x-prop
3926
- *
3927
- * @author Kjell-Inge Gustafsson <[email protected]>
3928
-	* @since 2.4.11 - 2008-11-04
3929
- * @param string $label
3930
- * @param mixed $value
3931
- * @param array $params optional
3932
- * @return bool
3933
- */
3934
-  function setXprop( $label, $value, $params=FALSE ) {
3924
+     * set calendar component property x-prop
3925
+     *
3926
+     * @author Kjell-Inge Gustafsson <[email protected]>
3927
+     * @since 2.4.11 - 2008-11-04
3928
+     * @param string $label
3929
+     * @param mixed $value
3930
+     * @param array $params optional
3931
+     * @return bool
3932
+     */
3933
+    function setXprop( $label, $value, $params=FALSE ) {
3935 3934
     if( empty( $label )) return;
3936 3935
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3937 3936
     $xprop           = array( 'value' => $value );
@@ -3940,7 +3939,7 @@  discard block
 block discarded – undo
3940 3939
     if( !is_array( $this->xprop )) $this->xprop = array();
3941 3940
     $this->xprop[strtoupper( $label )] = $xprop;
3942 3941
     return TRUE;
3943
-  }
3942
+    }
3944 3943
 /*********************************************************************************/
3945 3944
 /*********************************************************************************/
3946 3945
 /**
@@ -3950,10 +3949,10 @@  discard block
 block discarded – undo
3950 3949
  * @since 2.0.6 - 2006-06-20
3951 3950
  * @return string
3952 3951
  */
3953
-  function _createFormat() {
3952
+    function _createFormat() {
3954 3953
     $objectname                   = null;
3955 3954
     switch( $this->format ) {
3956
-      case 'xcal':
3955
+        case 'xcal':
3957 3956
         $objectname               = ( isset( $this->timezonetype )) ?
3958 3957
                                  strtolower( $this->timezonetype )  :  strtolower( $this->objName );
3959 3958
         $this->componentStart1    = $this->elementStart1 = '<';
@@ -3964,7 +3963,7 @@  discard block
 block discarded – undo
3964 3963
         $this->attributeDelimiter = $this->nl;
3965 3964
         $this->valueInit          = null;
3966 3965
         break;
3967
-      default:
3966
+        default:
3968 3967
         $objectname               = ( isset( $this->timezonetype )) ?
3969 3968
                                  strtoupper( $this->timezonetype )  :  strtoupper( $this->objName );
3970 3969
         $this->componentStart1    = 'BEGIN:';
@@ -3981,232 +3980,232 @@  discard block
 block discarded – undo
3981 3980
         break;
3982 3981
     }
3983 3982
     return $objectname;
3984
-  }
3983
+    }
3985 3984
 /**
3986
- * creates formatted output for calendar component property
3987
- *
3988
- * @author Kjell-Inge Gustafsson <[email protected]>
3989
- * @since 2.4.8 - 2008-10-23
3990
- * @param string $label property name
3991
- * @param string $attributes property attributes
3992
- * @param string $content property content (optional)
3993
- * @return string
3994
- */
3995
-  function _createElement( $label, $attributes=null, $content=FALSE ) {
3985
+     * creates formatted output for calendar component property
3986
+     *
3987
+     * @author Kjell-Inge Gustafsson <[email protected]>
3988
+     * @since 2.4.8 - 2008-10-23
3989
+     * @param string $label property name
3990
+     * @param string $attributes property attributes
3991
+     * @param string $content property content (optional)
3992
+     * @return string
3993
+     */
3994
+    function _createElement( $label, $attributes=null, $content=FALSE ) {
3996 3995
     $label  = $this->_formatPropertyName( $label );
3997 3996
     $output = $this->elementStart1.$label;
3998 3997
     $categoriesAttrLang = null;
3999 3998
     $attachInlineBinary = FALSE;
4000 3999
     $attachfmttype      = null;
4001 4000
     if( !empty( $attributes ))  {
4002
-      $attributes  = trim( $attributes );
4003
-      if ( 'xcal' == $this->format) {
4001
+        $attributes  = trim( $attributes );
4002
+        if ( 'xcal' == $this->format) {
4004 4003
         $attributes2 = explode( $this->intAttrDelimiter, $attributes );
4005 4004
         $attributes  = null;
4006 4005
         foreach( $attributes2 as $attribute ) {
4007
-          $attrKVarr = explode( '=', $attribute );
4008
-          if( empty( $attrKVarr[0] ))
4006
+            $attrKVarr = explode( '=', $attribute );
4007
+            if( empty( $attrKVarr[0] ))
4009 4008
             continue;
4010
-          if( !isset( $attrKVarr[1] )) {
4009
+            if( !isset( $attrKVarr[1] )) {
4011 4010
             $attrValue = $attrKVarr[0];
4012 4011
             $attrKey   = null;
4013
-          }
4014
-          elseif( 2 == count( $attrKVarr)) {
4012
+            }
4013
+            elseif( 2 == count( $attrKVarr)) {
4015 4014
             $attrKey   = strtolower( $attrKVarr[0] );
4016 4015
             $attrValue = $attrKVarr[1];
4017
-          }
4018
-          else {
4016
+            }
4017
+            else {
4019 4018
             $attrKey   = strtolower( $attrKVarr[0] );
4020 4019
             unset( $attrKVarr[0] );
4021 4020
             $attrValue = implode( '=', $attrKVarr );
4022
-          }
4023
-          if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4021
+            }
4022
+            if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4024 4023
             $attachInlineBinary = TRUE;
4025 4024
             if( 'fmttype' == $attrKey )
4026
-              $attachfmttype = $attrKey.'='.$attrValue;
4025
+                $attachfmttype = $attrKey.'='.$attrValue;
4027 4026
             continue;
4028
-          }
4029
-          elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4027
+            }
4028
+            elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4030 4029
             $categoriesAttrLang = $attrKey.'='.$attrValue;
4031
-          else {
4030
+            else {
4032 4031
             $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4033 4032
             $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4034 4033
             if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
4035
-              $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 ));
4036
-              $attrValue = str_replace( '"', '', $attrValue );
4034
+                $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 ));
4035
+                $attrValue = str_replace( '"', '', $attrValue );
4037 4036
             }
4038 4037
             $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4039
-          }
4038
+            }
4040 4039
         }
4041
-      }
4042
-      else {
4040
+        }
4041
+        else {
4043 4042
         $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4044
-      }
4043
+        }
4045 4044
     }
4046 4045
     if(((( 'attach' == $label ) && !$attachInlineBinary ) ||
4047 4046
          ( in_array( $label, array( 'tzurl', 'url' ))))      && ( 'xcal' == $this->format)) {
4048
-      $pos = strrpos($content, "/");
4049
-      $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content;
4050
-      $this->xcaldecl[] = array( 'xmldecl'  => 'ENTITY'
4051
-                               , 'uri'      => $docname
4052
-                               , 'ref'      => 'SYSTEM'
4053
-                               , 'external' => $content
4054
-                               , 'type'     => 'NDATA'
4055
-                               , 'type2'    => 'BINERY' );
4056
-      $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4057
-      $attributes .= 'uri="'.$docname.'"';
4058
-      $content = null;
4059
-      if( 'attach' == $label ) {
4047
+        $pos = strrpos($content, "/");
4048
+        $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content;
4049
+        $this->xcaldecl[] = array( 'xmldecl'  => 'ENTITY'
4050
+                                , 'uri'      => $docname
4051
+                                , 'ref'      => 'SYSTEM'
4052
+                                , 'external' => $content
4053
+                                , 'type'     => 'NDATA'
4054
+                                , 'type2'    => 'BINERY' );
4055
+        $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4056
+        $attributes .= 'uri="'.$docname.'"';
4057
+        $content = null;
4058
+        if( 'attach' == $label ) {
4060 4059
         $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes );
4061 4060
         $content = $this->_createElement( 'extref', $attributes, null );
4062 4061
         $attributes = null;
4063
-      }
4062
+        }
4064 4063
     }
4065 4064
     elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4066
-      $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4065
+        $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4067 4066
     }
4068 4067
     $output .= $attributes;
4069 4068
     if( !$content ) {
4070
-      switch( $this->format ) {
4069
+        switch( $this->format ) {
4071 4070
         case 'xcal':
4072 4071
           $output .= ' /';
4073
-          $output .= $this->elementStart2;
4074
-          return $output;
4075
-          break;
4072
+            $output .= $this->elementStart2;
4073
+            return $output;
4074
+            break;
4076 4075
         default:
4077 4076
           $output .= $this->elementStart2.$this->valueInit;
4078
-          return $this->_size75( $output );
4079
-          break;
4080
-      }
4077
+            return $this->_size75( $output );
4078
+            break;
4079
+        }
4081 4080
     }
4082 4081
     $output .= $this->elementStart2;
4083 4082
     $output .= $this->valueInit.$content;
4084 4083
     switch( $this->format ) {
4085
-      case 'xcal':
4084
+        case 'xcal':
4086 4085
         return $output.$this->elementEnd1.$label.$this->elementEnd2;
4087 4086
         break;
4088
-      default:
4087
+        default:
4089 4088
         return $this->_size75( $output );
4090 4089
         break;
4091 4090
     }
4092
-  }
4091
+    }
4093 4092
 /**
4094
- * creates formatted output for calendar component property parameters
4095
- *
4096
- * @author Kjell-Inge Gustafsson <[email protected]>
4097
- * @since 0.9.22 - 2007-04-10
4098
- * @param array $params  optional
4099
- * @param array $ctrKeys optional
4100
- * @return string
4101
- */
4102
-  function _createParams( $params=array(), $ctrKeys=array() ) {
4093
+     * creates formatted output for calendar component property parameters
4094
+     *
4095
+     * @author Kjell-Inge Gustafsson <[email protected]>
4096
+     * @since 0.9.22 - 2007-04-10
4097
+     * @param array $params  optional
4098
+     * @param array $ctrKeys optional
4099
+     * @return string
4100
+     */
4101
+    function _createParams( $params=array(), $ctrKeys=array() ) {
4103 4102
     $attrLANG = $attr1 = $attr2 = null;
4104 4103
     $CNattrKey   = ( in_array( 'CN',       $ctrKeys )) ? TRUE : FALSE ;
4105 4104
     $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ;
4106 4105
     $CNattrExist = $LANGattrExist = FALSE;
4107 4106
     if( is_array( $params )) {
4108
-      foreach( $params as $paramKey => $paramValue ) {
4107
+        foreach( $params as $paramKey => $paramValue ) {
4109 4108
         if( is_int( $paramKey ))
4110
-          $attr2            .= $this->intAttrDelimiter.$paramValue;
4109
+            $attr2            .= $this->intAttrDelimiter.$paramValue;
4111 4110
         elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4112
-          $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4113
-          $LANGattrExist     = TRUE;
4111
+            $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4112
+            $LANGattrExist     = TRUE;
4114 4113
         }
4115 4114
         elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4116
-          $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4117
-          $CNattrExist       = TRUE;
4115
+            $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4116
+            $CNattrExist       = TRUE;
4118 4117
         }
4119 4118
         elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4120
-          $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4119
+            $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4121 4120
         elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4122
-          $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4121
+            $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4123 4122
         elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4124
-          $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4123
+            $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4125 4124
         else
4126
-          $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4127
-      }
4125
+            $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4126
+        }
4128 4127
     }
4129 4128
     if( !$LANGattrExist ) {
4130
-      $lang = $this->getConfig( 'language' );
4131
-      if(( $CNattrExist || $LANGattrKey ) && $lang )
4129
+        $lang = $this->getConfig( 'language' );
4130
+        if(( $CNattrExist || $LANGattrKey ) && $lang )
4132 4131
         $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4133 4132
     }
4134 4133
     return $attrLANG.$attr1.$attr2;
4135
-  }
4134
+    }
4136 4135
 /**
4137
- * check a date(-time) for an opt. timezone and if it is a DATE-TIME or DATE
4138
- *
4139
- * @author Kjell-Inge Gustafsson <[email protected]>
4140
- * @since 2.4.16 - 2008-10-25
4141
- * @param array $date, date to check
4142
- * @param int $parno, no of date parts (i.e. year, month.. .)
4143
- * @return array $params, property parameters
4144
- */
4145
-  function _chkdatecfg( $theDate, & $parno, & $params ) {
4136
+     * check a date(-time) for an opt. timezone and if it is a DATE-TIME or DATE
4137
+     *
4138
+     * @author Kjell-Inge Gustafsson <[email protected]>
4139
+     * @since 2.4.16 - 2008-10-25
4140
+     * @param array $date, date to check
4141
+     * @param int $parno, no of date parts (i.e. year, month.. .)
4142
+     * @return array $params, property parameters
4143
+     */
4144
+    function _chkdatecfg( $theDate, & $parno, & $params ) {
4146 4145
     if( isset( $params['TZID'] ))
4147
-      $parno = 6;
4146
+        $parno = 6;
4148 4147
     elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4149
-      $parno = 3;
4148
+        $parno = 3;
4150 4149
     else {
4151
-      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4150
+        if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4152 4151
         $parno = 7;
4153
-      if( is_array( $theDate )) {
4152
+        if( is_array( $theDate )) {
4154 4153
         if( isset( $theDate['timestamp'] ))
4155
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4154
+            $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4156 4155
         else
4157
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4156
+            $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4158 4157
         if( !empty( $tzid )) {
4159
-          $parno = 7;
4160
-          if( !$this->_isOffset( $tzid ))
4158
+            $parno = 7;
4159
+            if( !$this->_isOffset( $tzid ))
4161 4160
             $params['TZID'] = $tzid; // save only timezone
4162 4161
         }
4163 4162
         elseif( !$parno && ( 3 == count( $theDate )) && 
4164 4163
           ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4165
-          $parno = 3;
4164
+            $parno = 3;
4166 4165
         else
4167
-          $parno = 6;
4168
-      }
4169
-      else { // string
4166
+            $parno = 6;
4167
+        }
4168
+        else { // string
4170 4169
         $date = trim( $theDate );
4171 4170
         if( 'Z' == substr( $date, -1 ))
4172
-          $parno = 7; // UTC DATE-TIME
4171
+            $parno = 7; // UTC DATE-TIME
4173 4172
         elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && 
4174 4173
           ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4175
-          $parno = 3; // DATE
4174
+            $parno = 3; // DATE
4176 4175
         $date = $this->_date_time_string( $date, $parno );
4177 4176
         if( !empty( $date['tz'] )) {
4178
-          $parno = 7;
4179
-          if( !$this->_isOffset( $date['tz'] ))
4177
+            $parno = 7;
4178
+            if( !$this->_isOffset( $date['tz'] ))
4180 4179
             $params['TZID'] = $date['tz']; // save only timezone
4181 4180
         }
4182 4181
         elseif( empty( $parno ))
4183
-          $parno = 6;
4184
-      }
4185
-      if( isset( $params['TZID'] ))
4182
+            $parno = 6;
4183
+        }
4184
+        if( isset( $params['TZID'] ))
4186 4185
         $parno = 6;
4187 4186
     }
4188
-  }
4187
+    }
4189 4188
 /**
4190
- * convert local startdate/enddate (Ymd[His]) to duration
4191
- *
4192
- * uses this component dates if missing input dates
4193
- *
4194
- * @author Kjell-Inge Gustafsson <[email protected]>
4195
- * @since 2.2.11 - 2007-11-03
4196
- * @param array $startdate, optional
4197
- * @param array $duration, optional
4198
- * @return array duration
4199
- */
4200
-  function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4189
+     * convert local startdate/enddate (Ymd[His]) to duration
4190
+     *
4191
+     * uses this component dates if missing input dates
4192
+     *
4193
+     * @author Kjell-Inge Gustafsson <[email protected]>
4194
+     * @since 2.2.11 - 2007-11-03
4195
+     * @param array $startdate, optional
4196
+     * @param array $duration, optional
4197
+     * @return array duration
4198
+     */
4199
+    function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4201 4200
     if( !$startdate || !$enddate ) {
4202
-      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4201
+        if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4203 4202
         return null;
4204
-      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4203
+        if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4205 4204
         if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4206
-          return null;
4205
+            return null;
4207 4206
     }
4208 4207
     if( !$startdate || !$enddate )
4209
-      return null;
4208
+        return null;
4210 4209
     $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4211 4210
     $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4212 4211
     $wduration   = $endWdate - $startWdate;
@@ -4220,137 +4219,137 @@  discard block
 block discarded – undo
4220 4219
     $dur['min']  = (int) floor( $wduration / ( 60 ));
4221 4220
     $dur['sec']  = (int)        $wduration % ( 60 );
4222 4221
     return $dur;
4223
-  }
4222
+    }
4224 4223
 /**
4225
- * convert date/datetime to timestamp
4226
- *
4227
- * @author Kjell-Inge Gustafsson <[email protected]>
4228
- * @since 2.4.8 - 2008-10-30
4229
- * @param array  $datetime  datetime/(date)
4230
- * @param string $tz        timezone
4231
- * @return timestamp
4232
- */
4233
-  function _date2timestamp( $datetime, $tz=null ) {
4224
+     * convert date/datetime to timestamp
4225
+     *
4226
+     * @author Kjell-Inge Gustafsson <[email protected]>
4227
+     * @since 2.4.8 - 2008-10-30
4228
+     * @param array  $datetime  datetime/(date)
4229
+     * @param string $tz        timezone
4230
+     * @return timestamp
4231
+     */
4232
+    function _date2timestamp( $datetime, $tz=null ) {
4234 4233
     $output = null;
4235 4234
     if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4236 4235
     if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4237 4236
     if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4238 4237
     foreach( $datetime as $dkey => $dvalue ) {
4239
-      if( 'tz' != $dkey )
4238
+        if( 'tz' != $dkey )
4240 4239
         $datetime[$dkey] = (integer) $dvalue;
4241 4240
     }
4242 4241
     if( $tz )
4243
-      $datetime['tz'] = $tz;
4242
+        $datetime['tz'] = $tz;
4244 4243
     $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4245 4244
     $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4246 4245
     return $output;
4247
-  }
4246
+    }
4248 4247
 /**
4249
- * ensures internal date-time/date format for input date-time/date in array format
4250
- *
4251
- * @author Kjell-Inge Gustafsson <[email protected]>
4252
- * @since 0.3.0 - 2006-08-15
4253
- * @param array $datetime
4254
- * @param int $parno optional, default FALSE
4255
- * @return array
4256
- */
4257
-  function _date_time_array( $datetime, $parno=FALSE ) {
4248
+     * ensures internal date-time/date format for input date-time/date in array format
4249
+     *
4250
+     * @author Kjell-Inge Gustafsson <[email protected]>
4251
+     * @since 0.3.0 - 2006-08-15
4252
+     * @param array $datetime
4253
+     * @param int $parno optional, default FALSE
4254
+     * @return array
4255
+     */
4256
+    function _date_time_array( $datetime, $parno=FALSE ) {
4258 4257
     $output = array();
4259 4258
     foreach( $datetime as $dateKey => $datePart ) {
4260
-      switch ( $dateKey ) {
4259
+        switch ( $dateKey ) {
4261 4260
         case '0': case 'year':   $output['year']  = $datePart; break;
4262 4261
         case '1': case 'month':  $output['month'] = $datePart; break;
4263 4262
         case '2': case 'day':    $output['day']   = $datePart; break;
4264
-      }
4265
-      if( 3 != $parno ) {
4263
+        }
4264
+        if( 3 != $parno ) {
4266 4265
         switch ( $dateKey ) {
4267
-          case '0':
4266
+            case '0':
4268 4267
           case '1':
4269 4268
           case '2': break;
4270
-          case '3': case 'hour': $output['hour']  = $datePart; break;
4271
-          case '4': case 'min' : $output['min']   = $datePart; break;
4272
-          case '5': case 'sec' : $output['sec']   = $datePart; break;
4273
-          case '6': case 'tz'  : $output['tz']    = $datePart; break;
4269
+            case '3': case 'hour': $output['hour']  = $datePart; break;
4270
+            case '4': case 'min' : $output['min']   = $datePart; break;
4271
+            case '5': case 'sec' : $output['sec']   = $datePart; break;
4272
+            case '6': case 'tz'  : $output['tz']    = $datePart; break;
4273
+        }
4274 4274
         }
4275
-      }
4276 4275
     }
4277 4276
     if( 3 != $parno ) {
4278
-      if( !isset( $output['hour'] ))
4277
+        if( !isset( $output['hour'] ))
4279 4278
         $output['hour'] = 0;
4280
-      if( !isset( $output['min']  ))
4279
+        if( !isset( $output['min']  ))
4281 4280
         $output['min'] = 0;
4282
-      if( !isset( $output['sec']  ))
4281
+        if( !isset( $output['sec']  ))
4283 4282
         $output['sec'] = 0;
4284 4283
     }
4285 4284
     return $output;
4286
-  }
4285
+    }
4287 4286
 /**
4288
- * ensures internal date-time/date format for input date-time/date in string fromat
4289
- *
4290
- * @author Kjell-Inge Gustafsson <[email protected]>
4291
- * @since 2.2.10 - 2007-10-19
4292
- * @param array $datetime
4293
- * @param int $parno optional, default FALSE
4294
- * @return array
4295
- */
4296
-  function _date_time_string( $datetime, $parno=FALSE ) {
4287
+     * ensures internal date-time/date format for input date-time/date in string fromat
4288
+     *
4289
+     * @author Kjell-Inge Gustafsson <[email protected]>
4290
+     * @since 2.2.10 - 2007-10-19
4291
+     * @param array $datetime
4292
+     * @param int $parno optional, default FALSE
4293
+     * @return array
4294
+     */
4295
+    function _date_time_string( $datetime, $parno=FALSE ) {
4297 4296
     $datetime = (string) trim( $datetime );
4298 4297
     $tz  = null;
4299 4298
     $len = strlen( $datetime ) - 1;
4300 4299
     if( 'Z' == substr( $datetime, -1 )) {
4301
-      $tz = 'Z';
4302
-      $datetime = trim( substr( $datetime, 0, $len ));
4300
+        $tz = 'Z';
4301
+        $datetime = trim( substr( $datetime, 0, $len ));
4303 4302
     }
4304 4303
     elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4305 4304
                   ( '-' == substr( $datetime, -3, 1 )) ||
4306 4305
                   ( ':' == substr( $datetime, -3, 1 )) ||
4307 4306
                   ( '.' == substr( $datetime, -3, 1 ))) {
4308
-      $continue = TRUE;
4307
+        $continue = TRUE;
4309 4308
     }
4310 4309
     elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4311 4310
             ( ' +' == substr( $datetime, -6, 2 )) ||
4312 4311
             ( ' -' == substr( $datetime, -6, 2 ))) {
4313
-      $tz = substr( $datetime, -5, 5 );
4314
-      $datetime = substr( $datetime, 0, ($len - 5));
4312
+        $tz = substr( $datetime, -5, 5 );
4313
+        $datetime = substr( $datetime, 0, ($len - 5));
4315 4314
     }
4316 4315
     elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4317 4316
             ( ' +' == substr( $datetime, -8, 2 )) ||
4318 4317
             ( ' -' == substr( $datetime, -8, 2 ))) {
4319
-      $tz = substr( $datetime, -7, 7 );
4320
-      $datetime = substr( $datetime, 0, ($len - 7));
4318
+        $tz = substr( $datetime, -7, 7 );
4319
+        $datetime = substr( $datetime, 0, ($len - 7));
4321 4320
     }
4322 4321
     elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4323
-      $continue = TRUE;
4322
+        $continue = TRUE;
4324 4323
     }
4325 4324
     elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4326
-      $continue = TRUE;
4325
+        $continue = TRUE;
4327 4326
     }
4328 4327
     else {
4329
-      $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4330
-      for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4328
+        $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4329
+        for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4331 4330
         if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4332
-          break; // if exists, tz ends here.. . ?
4331
+            break; // if exists, tz ends here.. . ?
4333 4332
         elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4334 4333
              ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4335
-          $tx--; // tz length counter
4336
-      }
4337
-      if( 0 > $tx ) {
4334
+            $tx--; // tz length counter
4335
+        }
4336
+        if( 0 > $tx ) {
4338 4337
         $tz = substr( $datetime, $tx );
4339 4338
         $datetime = trim( substr( $datetime, 0, $len + $tx + 1 ));
4340
-      }
4339
+        }
4341 4340
     }
4342 4341
     if( 0 < substr_count( $datetime, '-' )) {
4343
-      $datetime = str_replace( '-', '/', $datetime );
4342
+        $datetime = str_replace( '-', '/', $datetime );
4344 4343
     }
4345 4344
     elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4346 4345
            ( 'T' ==      substr( $datetime, 8, 1 )) &&
4347 4346
             ctype_digit( substr( $datetime, 9, 6 ))) {
4348
-      $datetime = substr( $datetime,  4, 2 )
4349
-             .'/'.substr( $datetime,  6, 2 )
4350
-             .'/'.substr( $datetime,  0, 4 )
4351
-             .' '.substr( $datetime,  9, 2 )
4352
-             .':'.substr( $datetime, 11, 2 )
4353
-             .':'.substr( $datetime, 13);
4347
+        $datetime = substr( $datetime,  4, 2 )
4348
+                .'/'.substr( $datetime,  6, 2 )
4349
+                .'/'.substr( $datetime,  0, 4 )
4350
+                .' '.substr( $datetime,  9, 2 )
4351
+                .':'.substr( $datetime, 11, 2 )
4352
+                .':'.substr( $datetime, 13);
4354 4353
     }
4355 4354
     $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime ));
4356 4355
     $tz                = trim( $tz );
@@ -4359,112 +4358,112 @@  discard block
 block discarded – undo
4359 4358
     $output['month']   = substr( $datestring, 5, 2 );
4360 4359
     $output['day']     = substr( $datestring, 8, 2 );
4361 4360
     if(( 6 == $parno ) || ( 7 == $parno )) {
4362
-      $output['hour']  = substr( $datestring, 11, 2 );
4363
-      $output['min']   = substr( $datestring, 14, 2 );
4364
-      $output['sec']   = substr( $datestring, 17, 2 );
4365
-      if( !empty( $tz ))
4361
+        $output['hour']  = substr( $datestring, 11, 2 );
4362
+        $output['min']   = substr( $datestring, 14, 2 );
4363
+        $output['sec']   = substr( $datestring, 17, 2 );
4364
+        if( !empty( $tz ))
4366 4365
         $output['tz']  = $tz;
4367 4366
     }
4368 4367
     elseif( 3 != $parno ) {
4369
-      if(( '00' < substr( $datestring, 11, 2 )) ||
4368
+        if(( '00' < substr( $datestring, 11, 2 )) ||
4370 4369
          ( '00' < substr( $datestring, 14, 2 )) ||
4371 4370
          ( '00' < substr( $datestring, 17, 2 ))) {
4372 4371
         $output['hour']  = substr( $datestring, 11, 2 );
4373 4372
         $output['min']   = substr( $datestring, 14, 2 );
4374 4373
         $output['sec']   = substr( $datestring, 17, 2 );
4375
-      }
4376
-      if( !empty( $tz ))
4374
+        }
4375
+        if( !empty( $tz ))
4377 4376
         $output['tz']  = $tz;
4378 4377
     }
4379 4378
     return $output;
4380
-  }
4379
+    }
4381 4380
 /**
4382
- * ensures internal duration format for input in array format
4383
- *
4384
- * @author Kjell-Inge Gustafsson <[email protected]>
4385
- * @since 2.1.1 - 2007-06-24
4386
- * @param array $duration
4387
- * @return array
4388
- */
4389
-  function _duration_array( $duration ) {
4381
+     * ensures internal duration format for input in array format
4382
+     *
4383
+     * @author Kjell-Inge Gustafsson <[email protected]>
4384
+     * @since 2.1.1 - 2007-06-24
4385
+     * @param array $duration
4386
+     * @return array
4387
+     */
4388
+    function _duration_array( $duration ) {
4390 4389
     $output = array();
4391 4390
     if(    is_array( $duration )        &&
4392 4391
        ( 1 == count( $duration ))       &&
4393 4392
               isset( $duration['sec'] ) &&
4394 4393
               ( 60 < $duration['sec'] )) {
4395
-      $durseconds  = $duration['sec'];
4396
-      $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 ));
4397
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 * 7 );
4398
-      $output['day']  = floor( $durseconds / ( 60 * 60 * 24 ));
4399
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 );
4400
-      $output['hour'] = floor( $durseconds / ( 60 * 60 ));
4401
-      $durseconds  =           $durseconds % ( 60 * 60 );
4402
-      $output['min']  = floor( $durseconds / ( 60 ));
4403
-      $output['sec']  =      ( $durseconds % ( 60 ));
4394
+        $durseconds  = $duration['sec'];
4395
+        $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 ));
4396
+        $durseconds  =           $durseconds % ( 60 * 60 * 24 * 7 );
4397
+        $output['day']  = floor( $durseconds / ( 60 * 60 * 24 ));
4398
+        $durseconds  =           $durseconds % ( 60 * 60 * 24 );
4399
+        $output['hour'] = floor( $durseconds / ( 60 * 60 ));
4400
+        $durseconds  =           $durseconds % ( 60 * 60 );
4401
+        $output['min']  = floor( $durseconds / ( 60 ));
4402
+        $output['sec']  =      ( $durseconds % ( 60 ));
4404 4403
     }
4405 4404
     else {
4406
-      foreach( $duration as $durKey => $durValue ) {
4405
+        foreach( $duration as $durKey => $durValue ) {
4407 4406
         if( empty( $durValue )) continue;
4408 4407
         switch ( $durKey ) {
4409
-          case '0': case 'week': $output['week']  = $durValue; break;
4410
-          case '1': case 'day':  $output['day']   = $durValue; break;
4411
-          case '2': case 'hour': $output['hour']  = $durValue; break;
4412
-          case '3': case 'min':  $output['min']   = $durValue; break;
4413
-          case '4': case 'sec':  $output['sec']   = $durValue; break;
4408
+            case '0': case 'week': $output['week']  = $durValue; break;
4409
+            case '1': case 'day':  $output['day']   = $durValue; break;
4410
+            case '2': case 'hour': $output['hour']  = $durValue; break;
4411
+            case '3': case 'min':  $output['min']   = $durValue; break;
4412
+            case '4': case 'sec':  $output['sec']   = $durValue; break;
4413
+        }
4414 4414
         }
4415
-      }
4416 4415
     }
4417 4416
     if( isset( $output['week'] ) && ( 0 < $output['week'] )) {
4418
-      unset( $output['day'], $output['hour'], $output['min'], $output['sec'] );
4419
-      return $output;
4417
+        unset( $output['day'], $output['hour'], $output['min'], $output['sec'] );
4418
+        return $output;
4420 4419
     }
4421 4420
     unset( $output['week'] );
4422 4421
     if( empty( $output['day'] ))
4423
-      unset( $output['day'] );
4422
+        unset( $output['day'] );
4424 4423
     if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4425
-      if( !isset( $output['hour'] )) $output['hour'] = 0;
4426
-      if( !isset( $output['min']  )) $output['min']  = 0;
4427
-      if( !isset( $output['sec']  )) $output['sec']  = 0;
4428
-      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4424
+        if( !isset( $output['hour'] )) $output['hour'] = 0;
4425
+        if( !isset( $output['min']  )) $output['min']  = 0;
4426
+        if( !isset( $output['sec']  )) $output['sec']  = 0;
4427
+        if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4429 4428
         unset( $output['hour'], $output['min'], $output['sec'] );
4430 4429
     }
4431 4430
     return $output;
4432
-  }
4431
+    }
4433 4432
 /**
4434
- * convert duration to date in array format based on input or dtstart value
4435
- *
4436
- * @author Kjell-Inge Gustafsson <[email protected]>
4437
- * @since 2.4.8 - 2008-10-30
4438
- * @param array $startdate, optional
4439
- * @param array $duration, optional
4440
- * @return array, date format
4441
- */
4442
-  function duration2date( $startdate=FALSE, $duration=FALSE ) {
4433
+     * convert duration to date in array format based on input or dtstart value
4434
+     *
4435
+     * @author Kjell-Inge Gustafsson <[email protected]>
4436
+     * @since 2.4.8 - 2008-10-30
4437
+     * @param array $startdate, optional
4438
+     * @param array $duration, optional
4439
+     * @return array, date format
4440
+     */
4441
+    function duration2date( $startdate=FALSE, $duration=FALSE ) {
4443 4442
     if( $startdate && $duration ) {
4444
-      $d1               = $startdate;
4445
-      $dur              = $duration;
4443
+        $d1               = $startdate;
4444
+        $dur              = $duration;
4446 4445
     }
4447 4446
     elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4448
-      $d1               = $this->dtstart['value'];
4449
-      $dur              = $this->duration['value'];
4447
+        $d1               = $this->dtstart['value'];
4448
+        $dur              = $this->duration['value'];
4450 4449
     }
4451 4450
     else
4452
-      return null;
4451
+        return null;
4453 4452
     $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4454 4453
     $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4455 4454
     $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4456 4455
     $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4457 4456
     $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4458 4457
     if( isset( $dur['week'] ))
4459
-      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4458
+        $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4460 4459
     if( isset( $dur['day'] ))
4461
-      $dtend += ( $dur['day'] * 24 * 60 * 60 );
4460
+        $dtend += ( $dur['day'] * 24 * 60 * 60 );
4462 4461
     if( isset( $dur['hour'] ))
4463
-      $dtend += ( $dur['hour'] * 60 *60 );
4462
+        $dtend += ( $dur['hour'] * 60 *60 );
4464 4463
     if( isset( $dur['min'] ))
4465
-      $dtend += ( $dur['min'] * 60 );
4464
+        $dtend += ( $dur['min'] * 60 );
4466 4465
     if( isset( $dur['sec'] ))
4467
-      $dtend +=   $dur['sec'];
4466
+        $dtend +=   $dur['sec'];
4468 4467
     $dtend2 = array();
4469 4468
     $dtend2['year']   = date('Y', $dtend );
4470 4469
     $dtend2['month']  = date('m', $dtend );
@@ -4473,112 +4472,112 @@  discard block
 block discarded – undo
4473 4472
     $dtend2['min']    = date('i', $dtend );
4474 4473
     $dtend2['sec']    = date('s', $dtend );
4475 4474
     if( isset( $d1['tz'] ))
4476
-      $dtend2['tz']   = $d1['tz'];
4475
+        $dtend2['tz']   = $d1['tz'];
4477 4476
     if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4478
-      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
4477
+        unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
4479 4478
     return $dtend2;
4480
-  }
4479
+    }
4481 4480
 /**
4482
- * ensures internal duration format for input in string format
4483
- *
4484
- * @author Kjell-Inge Gustafsson <[email protected]>
4485
- * @since 2.0.5 - 2007-03-14
4486
- * @param string $duration
4487
- * @return array
4488
- */
4489
-  function _duration_string( $duration ) {
4490
-   $duration = (string) trim( $duration );
4491
-   while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4492
-     if( 0 < strlen( $duration ))
4493
-       $duration = substr( $duration, 1 );
4494
-     else
4495
-       return false; // no leading P !?!?
4496
-   }
4497
-   $duration = substr( $duration, 1 ); // skip P
4498
-   $duration = str_replace ( 't', 'T', $duration );
4499
-   $duration = str_replace ( 'T', '', $duration );
4500
-   $output = array();
4501
-   $val    = null;
4502
-   for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
4503
-     switch( strtoupper( $duration{$ix} )) {
4504
-      case 'W':
4481
+     * ensures internal duration format for input in string format
4482
+     *
4483
+     * @author Kjell-Inge Gustafsson <[email protected]>
4484
+     * @since 2.0.5 - 2007-03-14
4485
+     * @param string $duration
4486
+     * @return array
4487
+     */
4488
+    function _duration_string( $duration ) {
4489
+    $duration = (string) trim( $duration );
4490
+    while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4491
+        if( 0 < strlen( $duration ))
4492
+        $duration = substr( $duration, 1 );
4493
+        else
4494
+        return false; // no leading P !?!?
4495
+    }
4496
+    $duration = substr( $duration, 1 ); // skip P
4497
+    $duration = str_replace ( 't', 'T', $duration );
4498
+    $duration = str_replace ( 'T', '', $duration );
4499
+    $output = array();
4500
+    $val    = null;
4501
+    for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
4502
+        switch( strtoupper( $duration{$ix} )) {
4503
+        case 'W':
4505 4504
         $output['week'] = $val;
4506 4505
         $val            = null;
4507 4506
         break;
4508
-      case 'D':
4507
+        case 'D':
4509 4508
         $output['day']  = $val;
4510 4509
         $val            = null;
4511 4510
         break;
4512
-      case 'H':
4511
+        case 'H':
4513 4512
         $output['hour'] = $val;
4514 4513
         $val            = null;
4515 4514
         break;
4516
-      case 'M':
4515
+        case 'M':
4517 4516
         $output['min']  = $val;
4518 4517
         $val            = null;
4519 4518
         break;
4520
-      case 'S':
4519
+        case 'S':
4521 4520
         $output['sec']  = $val;
4522 4521
         $val            = null;
4523 4522
         break;
4524
-      default:
4523
+        default:
4525 4524
         if( !ctype_digit( $duration{$ix} ))
4526
-          return false; // unknown duration controll character  !?!?
4525
+            return false; // unknown duration controll character  !?!?
4527 4526
         else
4528
-          $val .= $duration{$ix};
4529
-     }
4530
-   }
4531
-   return $this->_duration_array( $output );
4532
-  }
4533
-/**
4534
- * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue
4535
- *
4536
- * @author Kjell-Inge Gustafsson <[email protected]>
4537
- * @since 2.4.16 - 2008-11-08
4538
- * @param array $array
4539
- * @param string $expkey, expected key
4540
- * @param string $expval, expected value
4541
- * @param int $hitVal optional, return value if found
4542
- * @param int $elseVal optional, return value if not found
4543
- * @param int $preSet optional, return value if already preset
4544
- * @return int
4545
- */
4546
-  function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4527
+            $val .= $duration{$ix};
4528
+        }
4529
+    }
4530
+    return $this->_duration_array( $output );
4531
+    }
4532
+/**
4533
+     * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue
4534
+     *
4535
+     * @author Kjell-Inge Gustafsson <[email protected]>
4536
+     * @since 2.4.16 - 2008-11-08
4537
+     * @param array $array
4538
+     * @param string $expkey, expected key
4539
+     * @param string $expval, expected value
4540
+     * @param int $hitVal optional, return value if found
4541
+     * @param int $elseVal optional, return value if not found
4542
+     * @param int $preSet optional, return value if already preset
4543
+     * @return int
4544
+     */
4545
+    function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4547 4546
     if( $preSet )
4548
-      return $preSet;
4547
+        return $preSet;
4549 4548
     if( !is_array( $array ) || ( 0 == count( $array )))
4550
-      return $elseVal;
4549
+        return $elseVal;
4551 4550
     foreach( $array as $key => $value ) {
4552
-      if( strtoupper( $expkey ) == strtoupper( $key )) {
4551
+        if( strtoupper( $expkey ) == strtoupper( $key )) {
4553 4552
         if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
4554
-          unset( $array[$key] );
4555
-          return $hitVal;
4553
+            unset( $array[$key] );
4554
+            return $hitVal;
4555
+        }
4556 4556
         }
4557
-      }
4558 4557
     }
4559 4558
     return $elseVal;
4560
-  }
4559
+    }
4561 4560
 /**
4562
- * creates formatted output for calendar component property data value type date/date-time
4563
- *
4564
- * @author Kjell-Inge Gustafsson <[email protected]>
4565
- * @since 2.4.8 - 2008-10-30
4566
- * @param array   $datetime
4567
- * @param int     $parno, optional, default 6
4568
- * @return string
4569
- */
4570
-  function _format_date_time( $datetime, $parno=6 ) {
4561
+     * creates formatted output for calendar component property data value type date/date-time
4562
+     *
4563
+     * @author Kjell-Inge Gustafsson <[email protected]>
4564
+     * @since 2.4.8 - 2008-10-30
4565
+     * @param array   $datetime
4566
+     * @param int     $parno, optional, default 6
4567
+     * @return string
4568
+     */
4569
+    function _format_date_time( $datetime, $parno=6 ) {
4571 4570
     if( !isset( $datetime['year'] )  &&
4572 4571
         !isset( $datetime['month'] ) &&
4573 4572
         !isset( $datetime['day'] )   &&
4574 4573
         !isset( $datetime['hour'] )  &&
4575 4574
         !isset( $datetime['min'] )   &&
4576 4575
         !isset( $datetime['sec'] ))
4577
-      return ;
4576
+        return ;
4578 4577
     $output = null;
4579 4578
     // 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"; }
4580 4579
     foreach( $datetime as $dkey => $dvalue ) {
4581
-      if( 'tz' != $dkey )
4580
+        if( 'tz' != $dkey )
4582 4581
         $datetime[$dkey] = (integer) $dvalue;
4583 4582
     }
4584 4583
     $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
@@ -4586,101 +4585,101 @@  discard block
 block discarded – undo
4586 4585
         isset( $datetime['min'] )   ||
4587 4586
         isset( $datetime['sec'] )   ||
4588 4587
         isset( $datetime['tz'] )) {
4589
-      if( isset( $datetime['tz'] )  &&
4588
+        if( isset( $datetime['tz'] )  &&
4590 4589
          !isset( $datetime['hour'] ))
4591 4590
         $datetime['hour'] = 0;
4592
-      if( isset( $datetime['hour'] )  &&
4591
+        if( isset( $datetime['hour'] )  &&
4593 4592
          !isset( $datetime['min'] ))
4594 4593
         $datetime['min'] = 0;
4595
-      if( isset( $datetime['hour'] )  &&
4594
+        if( isset( $datetime['hour'] )  &&
4596 4595
           isset( $datetime['min'] )   &&
4597 4596
          !isset( $datetime['sec'] ))
4598 4597
         $datetime['sec'] = 0;
4599
-      $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600
-      $output .= date('\THis', $date );
4601
-      if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4598
+        $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4599
+        $output .= date('\THis', $date );
4600
+        if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4602 4601
         $datetime['tz'] = trim( $datetime['tz'] );
4603 4602
         if( 'Z' == $datetime['tz'] )
4604
-          $output .= 'Z';
4603
+            $output .= 'Z';
4605 4604
         $offset = $this->_tz2offset( $datetime['tz'] );
4606 4605
         if( 0 != $offset ) {
4607
-          $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608
-          $output    = date( 'Ymd\THis\Z', $date );
4606
+            $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4607
+            $output    = date( 'Ymd\THis\Z', $date );
4609 4608
         }
4610
-      }
4611
-      elseif( 7 == $parno )
4609
+        }
4610
+        elseif( 7 == $parno )
4612 4611
         $output .= 'Z';
4613 4612
     }
4614 4613
     return $output;
4615
-  }
4614
+    }
4616 4615
 /**
4617
- * creates formatted output for calendar component property data value type duration
4618
- *
4619
- * @author Kjell-Inge Gustafsson <[email protected]>
4620
- * @since 2.4.16 - 2008-10-10
4621
- * @param array $duration ( week, day, hour, min, sec )
4622
- * @return string
4623
- */
4624
-  function _format_duration( $duration ) {
4616
+     * creates formatted output for calendar component property data value type duration
4617
+     *
4618
+     * @author Kjell-Inge Gustafsson <[email protected]>
4619
+     * @since 2.4.16 - 2008-10-10
4620
+     * @param array $duration ( week, day, hour, min, sec )
4621
+     * @return string
4622
+     */
4623
+    function _format_duration( $duration ) {
4625 4624
     if( !isset( $duration['week'] ) &&
4626 4625
         !isset( $duration['day'] )  &&
4627 4626
         !isset( $duration['hour'] ) &&
4628 4627
         !isset( $duration['min'] )  &&
4629 4628
         !isset( $duration['sec'] ))
4630
-      return;
4629
+        return;
4631 4630
     $output = 'P';
4632 4631
     if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4633
-      $output   .= $duration['week'].'W';
4632
+        $output   .= $duration['week'].'W';
4634 4633
     else {
4635
-      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4634
+        if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4636 4635
         $output .= $duration['day'].'D';
4637
-      if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4636
+        if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4638 4637
          ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4639 4638
          ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
4640 4639
         $output .= 'T';
4641 4640
         $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H';
4642 4641
         $output .= ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ? $duration['min']. 'M' : '0M';
4643 4642
         $output .= ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))  ? $duration['sec']. 'S' : '0S';
4644
-      }
4643
+        }
4645 4644
     }
4646 4645
     return $output;
4647
-  }
4646
+    }
4648 4647
 /**
4649
- * creates formatted output for calendar component property data value type recur
4650
- *
4651
- * @author Kjell-Inge Gustafsson <[email protected]>
4652
- * @since 2.4.8 - 2008-10-22
4653
- * @param array $recurlabel
4654
- * @param array $recurdata
4655
- * @return string
4656
- */
4657
-  function _format_recur( $recurlabel, $recurdata ) {
4648
+     * creates formatted output for calendar component property data value type recur
4649
+     *
4650
+     * @author Kjell-Inge Gustafsson <[email protected]>
4651
+     * @since 2.4.8 - 2008-10-22
4652
+     * @param array $recurlabel
4653
+     * @param array $recurdata
4654
+     * @return string
4655
+     */
4656
+    function _format_recur( $recurlabel, $recurdata ) {
4658 4657
     $output = null;
4659 4658
     foreach( $recurdata as $therule ) {
4660
-      if( empty( $therule['value'] )) {
4659
+        if( empty( $therule['value'] )) {
4661 4660
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
4662 4661
         continue;
4663
-      }
4664
-      $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
4665
-      $content1  = $content2  = null;
4666
-      foreach( $therule['value'] as $rulelabel => $rulevalue ) {
4662
+        }
4663
+        $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
4664
+        $content1  = $content2  = null;
4665
+        foreach( $therule['value'] as $rulelabel => $rulevalue ) {
4667 4666
         switch( $rulelabel ) {
4668
-          case 'FREQ': {
4667
+            case 'FREQ': {
4669 4668
             $content1 .= "FREQ=$rulevalue";
4670 4669
             break;
4671
-          }
4672
-          case 'UNTIL': {
4670
+            }
4671
+            case 'UNTIL': {
4673 4672
             $content2 .= ";UNTIL=";
4674 4673
             $content2 .= $this->_format_date_time( $rulevalue );
4675 4674
             break;
4676
-          }
4677
-          case 'COUNT':
4675
+            }
4676
+            case 'COUNT':
4678 4677
           case 'INTERVAL':
4679 4678
           case 'WKST': {
4680 4679
             $content2 .= ";$rulelabel=$rulevalue";
4681 4680
             break;
4682
-          }
4683
-          case 'BYSECOND':
4681
+            }
4682
+            case 'BYSECOND':
4684 4683
           case 'BYMINUTE':
4685 4684
           case 'BYHOUR':
4686 4685
           case 'BYMONTHDAY':
@@ -4690,144 +4689,144 @@  discard block
 block discarded – undo
4690 4689
           case 'BYSETPOS': {
4691 4690
             $content2 .= ";$rulelabel=";
4692 4691
             if( is_array( $rulevalue )) {
4693
-              foreach( $rulevalue as $vix => $valuePart ) {
4692
+                foreach( $rulevalue as $vix => $valuePart ) {
4694 4693
                 $content2 .= ( $vix ) ? ',' : null;
4695 4694
                 $content2 .= $valuePart;
4696
-              }
4695
+                }
4697 4696
             }
4698 4697
             else
4699
-             $content2 .= $rulevalue;
4698
+                $content2 .= $rulevalue;
4700 4699
             break;
4701
-          }
4702
-          case 'BYDAY': {
4700
+            }
4701
+            case 'BYDAY': {
4703 4702
             $content2 .= ";$rulelabel=";
4704 4703
             $bydaycnt = 0;
4705 4704
             foreach( $rulevalue as $vix => $valuePart ) {
4706
-              $content21 = $content22 = null;
4707
-              if( is_array( $valuePart )) {
4705
+                $content21 = $content22 = null;
4706
+                if( is_array( $valuePart )) {
4708 4707
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4709 4708
                 foreach( $valuePart as $vix2 => $valuePart2 ) {
4710
-                  if( 'DAY' != strtoupper( $vix2 ))
4711
-                      $content21 .= $valuePart2;
4712
-                  else
4709
+                    if( 'DAY' != strtoupper( $vix2 ))
4710
+                        $content21 .= $valuePart2;
4711
+                    else
4713 4712
                     $content22 .= $valuePart2;
4714 4713
                 }
4715 4714
                 $content2 .= $content21.$content22;
4716 4715
                 $bydaycnt++;
4717
-              }
4718
-              else {
4716
+                }
4717
+                else {
4719 4718
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4720 4719
                 if( 'DAY' != strtoupper( $vix ))
4721 4720
                     $content21 .= $valuePart;
4722 4721
                 else {
4723
-                  $content22 .= $valuePart;
4724
-                  $bydaycnt++;
4722
+                    $content22 .= $valuePart;
4723
+                    $bydaycnt++;
4725 4724
                 }
4726 4725
                 $content2 .= $content21.$content22;
4727
-              }
4726
+                }
4728 4727
             }
4729 4728
             break;
4730
-          }
4731
-          default: {
4729
+            }
4730
+            default: {
4732 4731
             $content2 .= ";$rulelabel=$rulevalue";
4733 4732
             break;
4734
-          }
4733
+            }
4735 4734
         }
4736
-      }
4737
-      $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 );
4735
+        }
4736
+        $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 );
4738 4737
     }
4739 4738
     return $output;
4740
-  }
4739
+    }
4741 4740
 /**
4742
- * create property name case - lower/upper
4743
- *
4744
- * @author Kjell-Inge Gustafsson <[email protected]>
4745
- * @since 0.9.7 - 2006-11-20
4746
- * @param string $propertyName
4747
- * @return string
4748
- */
4749
-  function _formatPropertyName( $propertyName ) {
4741
+     * create property name case - lower/upper
4742
+     *
4743
+     * @author Kjell-Inge Gustafsson <[email protected]>
4744
+     * @since 0.9.7 - 2006-11-20
4745
+     * @param string $propertyName
4746
+     * @return string
4747
+     */
4748
+    function _formatPropertyName( $propertyName ) {
4750 4749
     switch( $this->format ) {
4751
-      case 'xcal':
4750
+        case 'xcal':
4752 4751
         return strtolower( $propertyName );
4753 4752
         break;
4754
-      default:
4753
+        default:
4755 4754
         return strtoupper( $propertyName );
4756 4755
         break;
4757 4756
     }
4758
-  }
4757
+    }
4759 4758
 /**
4760
- * checks if input array contains a date
4761
- *
4762
- * @author Kjell-Inge Gustafsson <[email protected]>
4763
- * @since 2.4.16 - 2008-10-25
4764
- * @param array $input
4765
- * @return bool
4766
- */
4767
-  function _isArrayDate( $input ) {
4759
+     * checks if input array contains a date
4760
+     *
4761
+     * @author Kjell-Inge Gustafsson <[email protected]>
4762
+     * @since 2.4.16 - 2008-10-25
4763
+     * @param array $input
4764
+     * @return bool
4765
+     */
4766
+    function _isArrayDate( $input ) {
4768 4767
     if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4769
-      return FALSE;
4768
+        return FALSE;
4770 4769
     if( 7 == count( $input ))
4771
-      return TRUE;
4770
+        return TRUE;
4772 4771
     if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4773
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4772
+        return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4774 4773
     if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4775
-      return FALSE;
4774
+        return FALSE;
4776 4775
     if( in_array( 0, $input ))
4777
-      return FALSE;
4776
+        return FALSE;
4778 4777
     if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4779
-      return FALSE;
4778
+        return FALSE;
4780 4779
     if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4781 4780
          checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4782
-      return TRUE;
4781
+        return TRUE;
4783 4782
     $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4784 4783
     if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4785
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4784
+        return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4786 4785
     return FALSE;
4787
-  }
4786
+    }
4788 4787
 /**
4789
- * checks if input array contains a timestamp date
4790
- *
4791
- * @author Kjell-Inge Gustafsson <[email protected]>
4792
- * @since 2.4.16 - 2008-10-18
4793
- * @param array $input
4794
- * @return bool
4795
- */
4796
-  function _isArrayTimestampDate( $input ) {
4788
+     * checks if input array contains a timestamp date
4789
+     *
4790
+     * @author Kjell-Inge Gustafsson <[email protected]>
4791
+     * @since 2.4.16 - 2008-10-18
4792
+     * @param array $input
4793
+     * @return bool
4794
+     */
4795
+    function _isArrayTimestampDate( $input ) {
4797 4796
     return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ;
4798
-  }
4797
+    }
4799 4798
 /**
4800
- * controll if input string contains traling UTC offset
4801
- *
4802
- * @author Kjell-Inge Gustafsson <[email protected]>
4803
- * @since 2.4.16 - 2008-10-19
4804
- * @param string $input
4805
- * @return bool
4806
- */
4807
-  function _isOffset( $input ) {
4799
+     * controll if input string contains traling UTC offset
4800
+     *
4801
+     * @author Kjell-Inge Gustafsson <[email protected]>
4802
+     * @since 2.4.16 - 2008-10-19
4803
+     * @param string $input
4804
+     * @return bool
4805
+     */
4806
+    function _isOffset( $input ) {
4808 4807
     $input         = trim( (string) $input );
4809 4808
     if( 'Z' == substr( $input, -1 ))
4810
-      return TRUE;
4809
+        return TRUE;
4811 4810
     elseif((   5 <= strlen( $input )) &&
4812 4811
        ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4813 4812
        (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4814
-      return TRUE;
4813
+        return TRUE;
4815 4814
     elseif((    7 <= strlen( $input )) &&
4816 4815
        ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4817 4816
        ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4818
-      return TRUE;
4817
+        return TRUE;
4819 4818
     return FALSE;
4820 4819
 
4821
-  }
4820
+    }
4822 4821
 /**
4823
- * check if property not exists within component
4824
- *
4825
- * @author Kjell-Inge Gustafsson <[email protected]>
4826
- * @since 2.5.1 - 2008-10-15
4827
- * @param string $propName
4828
- * @return bool
4829
- */
4830
-  function _notExistProp( $propName ) {
4822
+     * check if property not exists within component
4823
+     *
4824
+     * @author Kjell-Inge Gustafsson <[email protected]>
4825
+     * @since 2.5.1 - 2008-10-15
4826
+     * @param string $propName
4827
+     * @return bool
4828
+     */
4829
+    function _notExistProp( $propName ) {
4831 4830
     if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
4832 4831
     $propName = strtolower( $propName );
4833 4832
     if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
@@ -4837,270 +4836,270 @@  discard block
 block discarded – undo
4837 4836
     elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4838 4837
     elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
4839 4838
     return FALSE;
4840
-  }
4839
+    }
4841 4840
 /**
4842
- * remakes a recur pattern to an array of dates
4843
- *
4844
- * if missing, UNTIL is set 1 year from startdate (emergency break)
4845
- *
4846
- * @author Kjell-Inge Gustafsson <[email protected]>
4847
- * @since 2.4.16 - 2008-10-18
4848
- * @param array $result, array to update, array([timestamp] => timestamp)
4849
- * @param array $recur, pattern for recurrency (only value part, params ignored)
4850
- * @param array $wdate, component start date
4851
- * @param array $startdate, start date
4852
- * @param array $enddate, optional
4853
- * @return array of recurrence (start-)dates as index
4854
- * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4855
- */
4856
-  function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4841
+     * remakes a recur pattern to an array of dates
4842
+     *
4843
+     * if missing, UNTIL is set 1 year from startdate (emergency break)
4844
+     *
4845
+     * @author Kjell-Inge Gustafsson <[email protected]>
4846
+     * @since 2.4.16 - 2008-10-18
4847
+     * @param array $result, array to update, array([timestamp] => timestamp)
4848
+     * @param array $recur, pattern for recurrency (only value part, params ignored)
4849
+     * @param array $wdate, component start date
4850
+     * @param array $startdate, start date
4851
+     * @param array $enddate, optional
4852
+     * @return array of recurrence (start-)dates as index
4853
+     * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4854
+     */
4855
+    function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4857 4856
     foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
4858 4857
     $wdatets     = $this->_date2timestamp( $wdate );
4859 4858
     $startdatets = $this->_date2timestamp( $startdate );
4860 4859
     if( !$enddate ) {
4861
-      $enddate = $startdate;
4862
-      $enddate['year'] += 1;
4860
+        $enddate = $startdate;
4861
+        $enddate['year'] += 1;
4863 4862
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4864 4863
     }
4865 4864
     $endDatets = $this->_date2timestamp( $enddate ); // fix break
4866 4865
     if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4867
-      $recur['UNTIL'] = $enddate; // create break
4866
+        $recur['UNTIL'] = $enddate; // create break
4868 4867
     if( isset( $recur['UNTIL'] )) {
4869
-      $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4870
-      if( $endDatets > $tdatets ) {
4868
+        $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4869
+        if( $endDatets > $tdatets ) {
4871 4870
         $endDatets = $tdatets; // emergency break
4872 4871
         $enddate   = $this->_timestamp2date( $endDatets, 6 );
4873
-      }
4874
-      else
4872
+        }
4873
+        else
4875 4874
         $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4876 4875
     }
4877 4876
     if( $wdatets > $endDatets ) {
4878
-     //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4879
-      return array(); // nothing to do.. .
4877
+        //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4878
+        return array(); // nothing to do.. .
4880 4879
     }
4881 4880
     if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4882
-      $recur['FREQ'] = 'DAILY'; // ??
4881
+        $recur['FREQ'] = 'DAILY'; // ??
4883 4882
     $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4884 4883
     if( !isset( $recur['INTERVAL'] ))
4885
-      $recur['INTERVAL'] = 1;
4884
+        $recur['INTERVAL'] = 1;
4886 4885
     $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4887 4886
             /* find out how to step up dates and set index for interval count */
4888 4887
     $step = array();
4889 4888
     if( 'YEARLY' == $recur['FREQ'] )
4890
-      $step['year']  = 1;
4889
+        $step['year']  = 1;
4891 4890
     elseif( 'MONTHLY' == $recur['FREQ'] )
4892
-      $step['month'] = 1;
4891
+        $step['month'] = 1;
4893 4892
     elseif( 'WEEKLY' == $recur['FREQ'] )
4894
-      $step['day']   = 7;
4893
+        $step['day']   = 7;
4895 4894
     else
4896
-      $step['day']   = 1;
4895
+        $step['day']   = 1;
4897 4896
     if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4898
-      $step = array( 'month' => 1 );
4897
+        $step = array( 'month' => 1 );
4899 4898
     if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
4900
-      $step = array( 'day' => 7 );
4899
+        $step = array( 'day' => 7 );
4901 4900
     if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4902
-      $step = array( 'day' => 1 );
4901
+        $step = array( 'day' => 1 );
4903 4902
     $intervalarr = array();
4904 4903
     if( 1 < $recur['INTERVAL'] ) {
4905
-      $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
4906
-      $intervalarr = array( $intervalix => 0 );
4904
+        $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
4905
+        $intervalarr = array( $intervalix => 0 );
4907 4906
     }
4908 4907
     if( isset( $recur['BYSETPOS'] )) { // save start date + weekno
4909
-      $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array();
4910
-      $bysetposWold = (int) date( 'W', ( $wdatets + $wkst ));
4911
-      $bysetposYold = $wdate['year'];
4912
-      $bysetposMold = $wdate['month'];
4913
-      $bysetposDold = $wdate['day'];
4914
-      if( is_array( $recur['BYSETPOS'] )) {
4908
+        $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array();
4909
+        $bysetposWold = (int) date( 'W', ( $wdatets + $wkst ));
4910
+        $bysetposYold = $wdate['year'];
4911
+        $bysetposMold = $wdate['month'];
4912
+        $bysetposDold = $wdate['day'];
4913
+        if( is_array( $recur['BYSETPOS'] )) {
4915 4914
         foreach( $recur['BYSETPOS'] as $bix => $bval )
4916
-          $recur['BYSETPOS'][$bix] = (int) $bval;
4917
-      }
4918
-      else
4915
+            $recur['BYSETPOS'][$bix] = (int) $bval;
4916
+        }
4917
+        else
4919 4918
         $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4920
-      $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4919
+        $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4921 4920
     }
4922 4921
     $this->_stepdate( $wdate, $wdatets, $step);
4923 4922
     $year_old     = null;
4924 4923
     $daynames     = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' );
4925
-             /* MAIN LOOP */
4926
-     // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4924
+                /* MAIN LOOP */
4925
+        // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4927 4926
     while( TRUE ) {
4928
-      if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4927
+        if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4929 4928
         break;
4930
-      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4929
+        if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4931 4930
         break;
4932
-      if( $year_old != $wdate['year'] ) {
4931
+        if( $year_old != $wdate['year'] ) {
4933 4932
         $year_old   = $wdate['year'];
4934 4933
         $daycnts    = array();
4935 4934
         $yeardays   = $weekno = 0;
4936 4935
         $yeardaycnt = array();
4937 4936
         for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4938
-          $daycnts[$m] = array();
4939
-          $weekdaycnt = array();
4940
-          foreach( $daynames as $dn )
4937
+            $daycnts[$m] = array();
4938
+            $weekdaycnt = array();
4939
+            foreach( $daynames as $dn )
4941 4940
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4942
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4943
-          for( $d   = 1; $d <= $mcnt; $d++ ) {
4941
+            $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4942
+            for( $d   = 1; $d <= $mcnt; $d++ ) {
4944 4943
             $daycnts[$m][$d] = array();
4945 4944
             if( isset( $recur['BYYEARDAY'] )) {
4946
-              $yeardays++;
4947
-              $daycnts[$m][$d]['yearcnt_up'] = $yeardays;
4945
+                $yeardays++;
4946
+                $daycnts[$m][$d]['yearcnt_up'] = $yeardays;
4948 4947
             }
4949 4948
             if( isset( $recur['BYDAY'] )) {
4950
-              $day    = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] ));
4951
-              $day    = $daynames[$day];
4952
-              $daycnts[$m][$d]['DAY'] = $day;
4953
-              $weekdaycnt[$day]++;
4954
-              $daycnts[$m][$d]['monthdayno_up'] = $weekdaycnt[$day];
4955
-              $yeardaycnt[$day]++;
4956
-              $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4949
+                $day    = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] ));
4950
+                $day    = $daynames[$day];
4951
+                $daycnts[$m][$d]['DAY'] = $day;
4952
+                $weekdaycnt[$day]++;
4953
+                $daycnts[$m][$d]['monthdayno_up'] = $weekdaycnt[$day];
4954
+                $yeardaycnt[$day]++;
4955
+                $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4957 4956
             }
4958 4957
             if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4959
-              $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
4960
-          }
4958
+                $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
4959
+            }
4961 4960
         }
4962 4961
         $daycnt = 0;
4963 4962
         $yeardaycnt = array();
4964 4963
         if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4965
-          $weekno = null;
4966
-          for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4964
+            $weekno = null;
4965
+            for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4967 4966
             if( !$weekno )
4968
-              $weekno = $daycnts[12][$d]['weekno_up'];
4967
+                $weekno = $daycnts[12][$d]['weekno_up'];
4969 4968
             elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
4970
-              $weekno = $daycnts[12][$d]['weekno_up'];
4971
-              break;
4969
+                $weekno = $daycnts[12][$d]['weekno_up'];
4970
+                break;
4971
+            }
4972 4972
             }
4973
-          }
4974 4973
         }
4975 4974
         for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
4976
-          $weekdaycnt = array();
4977
-          foreach( $daynames as $dn )
4975
+            $weekdaycnt = array();
4976
+            foreach( $daynames as $dn )
4978 4977
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4979
-          $monthcnt = 0;
4980
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4981
-          for( $d   = $mcnt; $d > 0; $d-- ) {
4978
+            $monthcnt = 0;
4979
+            $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4980
+            for( $d   = $mcnt; $d > 0; $d-- ) {
4982 4981
             if( isset( $recur['BYYEARDAY'] )) {
4983
-              $daycnt -= 1;
4984
-              $daycnts[$m][$d]['yearcnt_down'] = $daycnt;
4982
+                $daycnt -= 1;
4983
+                $daycnts[$m][$d]['yearcnt_down'] = $daycnt;
4985 4984
             }
4986 4985
             if( isset( $recur['BYMONTHDAY'] )) {
4987
-              $monthcnt -= 1;
4988
-              $daycnts[$m][$d]['monthcnt_down'] = $monthcnt;
4986
+                $monthcnt -= 1;
4987
+                $daycnts[$m][$d]['monthcnt_down'] = $monthcnt;
4989 4988
             }
4990 4989
             if( isset( $recur['BYDAY'] )) {
4991
-              $day  = $daycnts[$m][$d]['DAY'];
4992
-              $weekdaycnt[$day] -= 1;
4993
-              $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day];
4994
-              $yeardaycnt[$day] -= 1;
4995
-              $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4990
+                $day  = $daycnts[$m][$d]['DAY'];
4991
+                $weekdaycnt[$day] -= 1;
4992
+                $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day];
4993
+                $yeardaycnt[$day] -= 1;
4994
+                $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4996 4995
             }
4997 4996
             if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4998
-              $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
4999
-          }
4997
+                $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
4998
+            }
4999
+        }
5000 5000
         }
5001
-      }
5002 5001
             /* check interval */
5003
-      if( 1 < $recur['INTERVAL'] ) {
5002
+        if( 1 < $recur['INTERVAL'] ) {
5004 5003
             /* create interval index */
5005 5004
         $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
5006 5005
             /* check interval */
5007 5006
         $currentKey = array_keys( $intervalarr );
5008 5007
         $currentKey = end( $currentKey ); // get last index
5009 5008
         if( $currentKey != $intervalix )
5010
-          $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5009
+            $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5011 5010
         if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5012 5011
            ( 0 != $intervalarr[$intervalix] )) {
5013 5012
             /* step up date */
5014 5013
     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5015
-          $this->_stepdate( $wdate, $wdatets, $step);
5016
-          continue;
5014
+            $this->_stepdate( $wdate, $wdatets, $step);
5015
+            continue;
5017 5016
         }
5018 5017
         else // continue within the selected interval
5019
-          $intervalarr[$intervalix] = 0;
5020
-   //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5021
-      }
5022
-      $updateOK = TRUE;
5023
-      if( $updateOK && isset( $recur['BYMONTH'] ))
5018
+            $intervalarr[$intervalix] = 0;
5019
+    //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5020
+        }
5021
+        $updateOK = TRUE;
5022
+        if( $updateOK && isset( $recur['BYMONTH'] ))
5024 5023
         $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5025
-                                           , $wdate['month']
5026
-                                           ,($wdate['month'] - 13));
5027
-      if( $updateOK && isset( $recur['BYWEEKNO'] ))
5024
+                                            , $wdate['month']
5025
+                                            ,($wdate['month'] - 13));
5026
+        if( $updateOK && isset( $recur['BYWEEKNO'] ))
5028 5027
         $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5029
-                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5030
-                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5031
-      if( $updateOK && isset( $recur['BYYEARDAY'] ))
5028
+                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5029
+                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5030
+        if( $updateOK && isset( $recur['BYYEARDAY'] ))
5032 5031
         $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5033
-                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5034
-                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5035
-      if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5032
+                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5033
+                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5034
+        if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5036 5035
         $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5037
-                                           , $wdate['day']
5038
-                                           , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5036
+                                            , $wdate['day']
5037
+                                            , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5039 5038
     //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5040
-      if( $updateOK && isset( $recur['BYDAY'] )) {
5039
+        if( $updateOK && isset( $recur['BYDAY'] )) {
5041 5040
         $updateOK = FALSE;
5042 5041
         $m = $wdate['month'];
5043 5042
         $d = $wdate['day'];
5044 5043
         if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5045
-          $daynoexists = $daynosw = $daynamesw =  FALSE;
5046
-          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5044
+            $daynoexists = $daynosw = $daynamesw =  FALSE;
5045
+            if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5047 5046
             $daynamesw = TRUE;
5048
-          if( isset( $recur['BYDAY'][0] )) {
5047
+            if( isset( $recur['BYDAY'][0] )) {
5049 5048
             $daynoexists = TRUE;
5050 5049
             if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5051
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5050
+                $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5052 5051
                                                 , $daycnts[$m][$d]['monthdayno_up']
5053 5052
                                                 , $daycnts[$m][$d]['monthdayno_down'] );
5054 5053
             elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5055
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5054
+                $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5056 5055
                                                 , $daycnts[$m][$d]['yeardayno_up']
5057 5056
                                                 , $daycnts[$m][$d]['yeardayno_down'] );
5058
-          }
5059
-          if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5057
+            }
5058
+            if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5060 5059
              ( !$daynoexists && !$daynosw && $daynamesw )) {
5061 5060
             $updateOK = TRUE;
5062
-          }
5061
+            }
5063 5062
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5064 5063
         }
5065 5064
         else {
5066
-          foreach( $recur['BYDAY'] as $bydayvalue ) {
5065
+            foreach( $recur['BYDAY'] as $bydayvalue ) {
5067 5066
             $daynoexists = $daynosw = $daynamesw = FALSE;
5068 5067
             if( isset( $bydayvalue['DAY'] ) &&
5069 5068
                      ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5070
-              $daynamesw = TRUE;
5069
+                $daynamesw = TRUE;
5071 5070
             if( isset( $bydayvalue[0] )) {
5072
-              $daynoexists = TRUE;
5073
-              if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5071
+                $daynoexists = TRUE;
5072
+                if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5074 5073
                    isset( $recur['BYMONTH'] ))
5075 5074
                 $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5076
-                                                  , $daycnts[$m][$d]['monthdayno_up']
5077
-                                                  , $daycnts[$m][$d]['monthdayno_down'] );
5078
-              elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5075
+                                                    , $daycnts[$m][$d]['monthdayno_up']
5076
+                                                    , $daycnts[$m][$d]['monthdayno_down'] );
5077
+                elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5079 5078
                 $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5080
-                                                  , $daycnts[$m][$d]['yeardayno_up']
5081
-                                                  , $daycnts[$m][$d]['yeardayno_down'] );
5079
+                                                    , $daycnts[$m][$d]['yeardayno_up']
5080
+                                                    , $daycnts[$m][$d]['yeardayno_down'] );
5082 5081
             }
5083 5082
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5084 5083
             if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5085 5084
                ( !$daynoexists && !$daynosw && $daynamesw )) {
5086
-              $updateOK = TRUE;
5087
-              break;
5085
+                $updateOK = TRUE;
5086
+                break;
5087
+            }
5088 5088
             }
5089
-          }
5090 5089
         }
5091
-      }
5092
-      //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ###
5090
+        }
5091
+        //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ###
5093 5092
             /* check BYSETPOS */
5094
-      if( $updateOK ) {
5093
+        if( $updateOK ) {
5095 5094
         if( isset( $recur['BYSETPOS'] ) &&
5096 5095
           ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5097
-          if( isset( $recur['WEEKLY'] )) {
5096
+            if( isset( $recur['WEEKLY'] )) {
5098 5097
             if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5099
-              $bysetposw1[] = $wdatets;
5098
+                $bysetposw1[] = $wdatets;
5100 5099
             else
5101
-              $bysetposw2[] = $wdatets;
5102
-          }
5103
-          else {
5100
+                $bysetposw2[] = $wdatets;
5101
+            }
5102
+            else {
5104 5103
             if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5105 5104
                                             ( $bysetposYold == $wdate['year'] ))   ||
5106 5105
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
@@ -5110,418 +5109,418 @@  discard block
 block discarded – undo
5110 5109
                                            (( $bysetposYold == $wdate['year'] )  &&
5111 5110
                                             ( $bysetposMold == $wdate['month'])  &&
5112 5111
                                             ( $bysetposDold == $wdate['sday'] ))))
5113
-              $bysetposymd1[] = $wdatets;
5112
+                $bysetposymd1[] = $wdatets;
5114 5113
             else
5115
-              $bysetposymd2[] = $wdatets;
5116
-          }
5114
+                $bysetposymd2[] = $wdatets;
5115
+            }
5117 5116
         }
5118 5117
         else {
5119 5118
             /* update result array if BYSETPOS is set */
5120
-          $countcnt++;
5121
-          if( $startdatets <= $wdatets ) { // only output within period
5119
+            $countcnt++;
5120
+            if( $startdatets <= $wdatets ) { // only output within period
5122 5121
             $result[$wdatets] = TRUE;
5123
-          //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
5124
-          }
5125
-         //else echo "recur undate ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))." okdatstart ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$startdatets),6))."<br />\n";//test
5126
-          $updateOK = FALSE;
5122
+            //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
5123
+            }
5124
+            //else echo "recur undate ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))." okdatstart ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$startdatets),6))."<br />\n";//test
5125
+            $updateOK = FALSE;
5126
+        }
5127 5127
         }
5128
-      }
5129 5128
             /* step up date */
5130
-      $this->_stepdate( $wdate, $wdatets, $step);
5129
+        $this->_stepdate( $wdate, $wdatets, $step);
5131 5130
             /* check if BYSETPOS is set for updating result array */
5132
-      if( $updateOK && isset( $recur['BYSETPOS'] )) {
5131
+        if( $updateOK && isset( $recur['BYSETPOS'] )) {
5133 5132
         $bysetpos       = FALSE;
5134 5133
         if( isset( $recur['FREQ'] ) && ( 'YEARLY'  == $recur['FREQ'] ) &&
5135 5134
           ( $bysetposYold != $wdate['year'] )) {
5136
-          $bysetpos     = TRUE;
5137
-          $bysetposYold = $wdate['year'];
5135
+            $bysetpos     = TRUE;
5136
+            $bysetposYold = $wdate['year'];
5138 5137
         }
5139 5138
         elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5140 5139
          (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5141
-          $bysetpos     = TRUE;
5142
-          $bysetposYold = $wdate['year'];
5143
-          $bysetposMold = $wdate['month'];
5140
+            $bysetpos     = TRUE;
5141
+            $bysetposYold = $wdate['year'];
5142
+            $bysetposMold = $wdate['month'];
5144 5143
         }
5145 5144
         elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5146
-          $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147
-          if( $bysetposWold != $weekno ) {
5145
+            $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5146
+            if( $bysetposWold != $weekno ) {
5148 5147
             $bysetposWold = $weekno;
5149 5148
             $bysetpos     = TRUE;
5150
-          }
5149
+            }
5151 5150
         }
5152 5151
         elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5153 5152
          (( $bysetposYold != $wdate['year'] )  ||
5154 5153
           ( $bysetposMold != $wdate['month'] ) ||
5155 5154
           ( $bysetposDold != $wdate['sday'] ))) {
5156
-          $bysetpos     = TRUE;
5157
-          $bysetposYold = $wdate['year'];
5158
-          $bysetposMold = $wdate['month'];
5159
-          $bysetposDold = $wdate['day'];
5155
+            $bysetpos     = TRUE;
5156
+            $bysetposYold = $wdate['year'];
5157
+            $bysetposMold = $wdate['month'];
5158
+            $bysetposDold = $wdate['day'];
5160 5159
         }
5161 5160
         if( $bysetpos ) {
5162
-          if( isset( $recur['BYWEEKNO'] )) {
5161
+            if( isset( $recur['BYWEEKNO'] )) {
5163 5162
             $bysetposarr1 = & $bysetposw1;
5164 5163
             $bysetposarr2 = & $bysetposw2;
5165
-          }
5166
-          else {
5164
+            }
5165
+            else {
5167 5166
             $bysetposarr1 = & $bysetposymd1;
5168 5167
             $bysetposarr2 = & $bysetposymd2;
5169
-          }
5170
-          foreach( $recur['BYSETPOS'] as $ix ) {
5168
+            }
5169
+            foreach( $recur['BYSETPOS'] as $ix ) {
5171 5170
             if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5172
-              $ix = ( count( $bysetposarr1 ) + $ix + 1);
5171
+                $ix = ( count( $bysetposarr1 ) + $ix + 1);
5173 5172
             $ix--;
5174 5173
             if( isset( $bysetposarr1[$ix] )) {
5175
-              if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
5174
+                if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
5176 5175
                 $result[$bysetposarr1[$ix]] = TRUE;
5177
-       //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test
5178
-              }
5179
-              $countcnt++;
5176
+        //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test
5177
+                }
5178
+                $countcnt++;
5180 5179
             }
5181 5180
             if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5182
-              break;
5183
-          }
5184
-          $bysetposarr1 = $bysetposarr2;
5185
-          $bysetposarr2 = array();
5181
+                break;
5182
+            }
5183
+            $bysetposarr1 = $bysetposarr2;
5184
+            $bysetposarr2 = array();
5185
+        }
5186 5186
         }
5187
-      }
5188 5187
     }
5189
-  }
5190
-  function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5188
+    }
5189
+    function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5191 5190
     if( is_array( $BYvalue ) &&
5192 5191
       ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5193
-      return TRUE;
5192
+        return TRUE;
5194 5193
     elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5195
-      return TRUE;
5194
+        return TRUE;
5196 5195
     else
5197
-      return FALSE;
5198
-  }
5199
-  function _recurIntervalIx( $freq, $date, $wkst ) {
5196
+        return FALSE;
5197
+    }
5198
+    function _recurIntervalIx( $freq, $date, $wkst ) {
5200 5199
             /* create interval index */
5201 5200
     switch( $freq ) {
5202
-      case 'YEARLY':
5201
+        case 'YEARLY':
5203 5202
         $intervalix = $date['year'];
5204 5203
         break;
5205
-      case 'MONTHLY':
5204
+        case 'MONTHLY':
5206 5205
         $intervalix = $date['year'].'-'.$date['month'];
5207 5206
         break;
5208
-      case 'WEEKLY':
5207
+        case 'WEEKLY':
5209 5208
         $wdatets    = $this->_date2timestamp( $date );
5210 5209
         $intervalix = (int) date( 'W', ( $wdatets + $wkst ));
5211
-       break;
5212
-      case 'DAILY':
5210
+        break;
5211
+        case 'DAILY':
5213 5212
            default:
5214 5213
         $intervalix = $date['year'].'-'.$date['month'].'-'.$date['day'];
5215 5214
         break;
5216 5215
     }
5217 5216
     return $intervalix;
5218
-  }
5217
+    }
5219 5218
 /**
5220
- * convert input format for exrule and rrule to internal format
5221
- *
5222
- * @author Kjell-Inge Gustafsson <[email protected]>
5223
- * @since 2.4.16 - 2008-10-19
5224
- * @param array $rexrule
5225
- * @return array
5226
- */
5227
-  function _setRexrule( $rexrule ) {
5219
+     * convert input format for exrule and rrule to internal format
5220
+     *
5221
+     * @author Kjell-Inge Gustafsson <[email protected]>
5222
+     * @since 2.4.16 - 2008-10-19
5223
+     * @param array $rexrule
5224
+     * @return array
5225
+     */
5226
+    function _setRexrule( $rexrule ) {
5228 5227
     $input          = array();
5229 5228
     if( empty( $rexrule ))
5230
-      return $input;
5229
+        return $input;
5231 5230
     foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5232
-      $rexrulelabel = strtoupper( $rexrulelabel );
5233
-      if( 'UNTIL'  != $rexrulelabel )
5231
+        $rexrulelabel = strtoupper( $rexrulelabel );
5232
+        if( 'UNTIL'  != $rexrulelabel )
5234 5233
         $input[$rexrulelabel]   = $rexrulevalue;
5235
-      else {
5234
+        else {
5236 5235
         if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5237
-          $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5236
+            $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5238 5237
         elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5239
-          $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5238
+            $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5240 5239
         elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5241
-          $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5240
+            $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5242 5241
         if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5243
-          $input[$rexrulelabel]['tz'] = 'Z';
5244
-      }
5242
+            $input[$rexrulelabel]['tz'] = 'Z';
5243
+        }
5245 5244
     }
5246 5245
     return $input;
5247
-  }
5246
+    }
5248 5247
 /**
5249
- * convert format for input date to internal date with parameters
5250
- *
5251
- * @author Kjell-Inge Gustafsson <[email protected]>
5252
- * @since 2.4.17 - 2008-10-31
5253
- * @param mixed $year
5254
- * @param mixed $month optional
5255
- * @param int $day optional
5256
- * @param int $hour optional
5257
- * @param int $min optional
5258
- * @param int $sec optional
5259
- * @param array $params optional
5260
- * @param string $caller optional
5261
- * @return array
5262
- */
5263
-  function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) {
5248
+     * convert format for input date to internal date with parameters
5249
+     *
5250
+     * @author Kjell-Inge Gustafsson <[email protected]>
5251
+     * @since 2.4.17 - 2008-10-31
5252
+     * @param mixed $year
5253
+     * @param mixed $month optional
5254
+     * @param int $day optional
5255
+     * @param int $hour optional
5256
+     * @param int $min optional
5257
+     * @param int $sec optional
5258
+     * @param array $params optional
5259
+     * @param string $caller optional
5260
+     * @return array
5261
+     */
5262
+    function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) {
5264 5263
     $input = $parno = null;
5265 5264
     $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5266 5265
     if( $this->_isArrayDate( $year )) {
5267
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5268
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5269
-      if( isset( $input['params']['TZID'] )) {
5266
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5267
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5268
+        if( isset( $input['params']['TZID'] )) {
5270 5269
         $input['params']['VALUE'] = 'DATE-TIME';
5271 5270
         unset( $year['tz'] );
5272
-      }
5273
-      $hitval          = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6;
5274
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5275
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5276
-      $input['value']  = $this->_date_time_array( $year, $parno );
5271
+        }
5272
+        $hitval          = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6;
5273
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5274
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5275
+        $input['value']  = $this->_date_time_array( $year, $parno );
5277 5276
     }
5278 5277
     elseif( $this->_isArrayTimestampDate( $year )) {
5279
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5280
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5281
-      if( isset( $input['params']['TZID'] )) {
5278
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5279
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5280
+        if( isset( $input['params']['TZID'] )) {
5282 5281
         $input['params']['VALUE'] = 'DATE-TIME';
5283 5282
         unset( $year['tz'] );
5284
-      }
5285
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5286
-      $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5287
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5288
-      $input['value']  = $this->_timestamp2date( $year, $parno );
5283
+        }
5284
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5285
+        $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5286
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5287
+        $input['value']  = $this->_timestamp2date( $year, $parno );
5289 5288
     }
5290 5289
     elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5291
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5292
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5293
-      if( isset( $input['params']['TZID'] )) {
5290
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5291
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5292
+        if( isset( $input['params']['TZID'] )) {
5294 5293
         $input['params']['VALUE'] = 'DATE-TIME';
5295 5294
         $parno = 6;
5296
-      }
5297
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5298
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5299
-      $input['value']  = $this->_date_time_string( $year, $parno );
5295
+        }
5296
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5297
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5298
+        $input['value']  = $this->_date_time_string( $year, $parno );
5300 5299
     }
5301 5300
     else {
5302
-      if( is_array( $params )) {
5301
+        if( is_array( $params )) {
5303 5302
         if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5304 5303
         $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5305
-      }
5306
-      elseif( is_array( $tz )) {
5304
+        }
5305
+        elseif( is_array( $tz )) {
5307 5306
         $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5308 5307
         $tz = FALSE;
5309
-      }
5310
-      elseif( is_array( $hour )) {
5308
+        }
5309
+        elseif( is_array( $hour )) {
5311 5310
         $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5312 5311
         $hour = $min = $sec = $tz = FALSE;
5313
-      }
5314
-      if( isset( $input['params']['TZID'] )) {
5312
+        }
5313
+        if( isset( $input['params']['TZID'] )) {
5315 5314
         $tz            = null;
5316 5315
         $input['params']['VALUE'] = 'DATE-TIME';
5317
-      }
5318
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5319
-      $hitval          = ( !empty( $tz )) ? 7 : 6;
5320
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno );
5321
-      $input['value']  = array( 'year'  => $year, 'month' => $month, 'day'   => $day );
5322
-      if( 3 != $parno ) {
5316
+        }
5317
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5318
+        $hitval          = ( !empty( $tz )) ? 7 : 6;
5319
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno );
5320
+        $input['value']  = array( 'year'  => $year, 'month' => $month, 'day'   => $day );
5321
+        if( 3 != $parno ) {
5323 5322
         $input['value']['hour'] = ( $hour ) ? $hour : '0';
5324 5323
         $input['value']['min']  = ( $min )  ? $min  : '0';
5325 5324
         $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5326 5325
         if( !empty( $tz ))
5327
-          $input['value']['tz'] = $tz;
5328
-      }
5326
+            $input['value']['tz'] = $tz;
5327
+        }
5329 5328
     }
5330 5329
     if( 3 == $parno ) {
5331
-      $input['params']['VALUE'] = 'DATE';
5332
-      unset( $input['value']['tz'] );
5333
-      unset( $input['params']['TZID'] );
5330
+        $input['params']['VALUE'] = 'DATE';
5331
+        unset( $input['value']['tz'] );
5332
+        unset( $input['params']['TZID'] );
5334 5333
     }
5335 5334
     elseif( isset( $input['params']['TZID'] ))
5336
-      unset( $input['value']['tz'] );
5335
+        unset( $input['value']['tz'] );
5337 5336
     if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5338 5337
     if( isset( $input['value']['tz'] ))
5339
-      $input['value']['tz'] = (string) $input['value']['tz'];
5338
+        $input['value']['tz'] = (string) $input['value']['tz'];
5340 5339
     if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5341 5340
       ( !$this->_isOffset( $input['value']['tz'] )))
5342
-      $input['params']['TZID'] = $input['value']['tz'];
5341
+        $input['params']['TZID'] = $input['value']['tz'];
5343 5342
     return $input;
5344
-  }
5343
+    }
5345 5344
 /**
5346
- * convert format for input date (UTC) to internal date with parameters
5347
- *
5348
- * @author Kjell-Inge Gustafsson <[email protected]>
5349
- * @since 2.4.17 - 2008-10-31
5350
- * @param mixed $year
5351
- * @param mixed $month optional
5352
- * @param int $day optional
5353
- * @param int $hour optional
5354
- * @param int $min optional
5355
- * @param int $sec optional
5356
- * @param array $params optional
5357
- * @return array
5358
- */
5359
-  function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
5345
+     * convert format for input date (UTC) to internal date with parameters
5346
+     *
5347
+     * @author Kjell-Inge Gustafsson <[email protected]>
5348
+     * @since 2.4.17 - 2008-10-31
5349
+     * @param mixed $year
5350
+     * @param mixed $month optional
5351
+     * @param int $day optional
5352
+     * @param int $hour optional
5353
+     * @param int $min optional
5354
+     * @param int $sec optional
5355
+     * @param array $params optional
5356
+     * @return array
5357
+     */
5358
+    function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
5360 5359
     $input = null;
5361 5360
     if( $this->_isArrayDate( $year )) {
5362
-      $input['value']  = $this->_date_time_array( $year, 7 );
5363
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5361
+        $input['value']  = $this->_date_time_array( $year, 7 );
5362
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5364 5363
     }
5365 5364
     elseif( $this->_isArrayTimestampDate( $year )) {
5366
-      $input['value']  = $this->_timestamp2date( $year, 7 );
5367
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5365
+        $input['value']  = $this->_timestamp2date( $year, 7 );
5366
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5368 5367
     }
5369 5368
     elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5370
-      $input['value']  = $this->_date_time_string( $year, 7 );
5371
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5369
+        $input['value']  = $this->_date_time_string( $year, 7 );
5370
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5372 5371
     }
5373 5372
     else {
5374
-      $input['value']  = array( 'year'  => $year
5375
-                              , 'month' => $month
5376
-                              , 'day'   => $day
5377
-                              , 'hour'  => $hour
5378
-                              , 'min'   => $min
5379
-                              , 'sec'   => $sec );
5380
-      $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5373
+        $input['value']  = array( 'year'  => $year
5374
+                                , 'month' => $month
5375
+                                , 'day'   => $day
5376
+                                , 'hour'  => $hour
5377
+                                , 'min'   => $min
5378
+                                , 'sec'   => $sec );
5379
+        $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5381 5380
     }
5382 5381
     $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5383 5382
     if( !isset( $input['value']['hour'] ))
5384
-      $input['value']['hour'] = 0;
5383
+        $input['value']['hour'] = 0;
5385 5384
     if( !isset( $input['value']['min'] ))
5386
-      $input['value']['min'] = 0;
5385
+        $input['value']['min'] = 0;
5387 5386
     if( !isset( $input['value']['sec'] ))
5388
-      $input['value']['sec'] = 0;
5387
+        $input['value']['sec'] = 0;
5389 5388
     if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5390
-      $input['value']['tz'] = 'Z';
5389
+        $input['value']['tz'] = 'Z';
5391 5390
     return $input;
5392
-  }
5391
+    }
5393 5392
 /**
5394
- * check index and set (an indexed) content in multiple value array
5395
- *
5396
- * @author Kjell-Inge Gustafsson <[email protected]>
5397
- * @since 2.5.1 - 2008-11-06
5398
- * @param array $valArr
5399
- * @param mixed $value
5400
- * @param array $params
5401
- * @param array $defaults
5402
- * @param int $index
5403
- * @return void
5404
- */
5405
-  function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5393
+     * check index and set (an indexed) content in multiple value array
5394
+     *
5395
+     * @author Kjell-Inge Gustafsson <[email protected]>
5396
+     * @since 2.5.1 - 2008-11-06
5397
+     * @param array $valArr
5398
+     * @param mixed $value
5399
+     * @param array $params
5400
+     * @param array $defaults
5401
+     * @param int $index
5402
+     * @return void
5403
+     */
5404
+    function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5406 5405
     if( !is_array( $valArr )) $valArr = array();
5407 5406
     if( $index )
5408
-      $index = $index - 1;
5407
+        $index = $index - 1;
5409 5408
     elseif( 0 < count( $valArr )) {
5410
-      $index = end( array_keys( $valArr ));
5411
-      $index += 1;
5409
+        $index = end( array_keys( $valArr ));
5410
+        $index += 1;
5412 5411
     }
5413 5412
     else
5414
-      $index = 0;
5413
+        $index = 0;
5415 5414
     $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5416 5415
     ksort( $valArr );
5417
-  }
5416
+    }
5418 5417
 /**
5419
- * set input (formatted) parameters- component property attributes
5420
- *
5421
- * default parameters can be set, if missing
5422
- *
5423
- * @author Kjell-Inge Gustafsson <[email protected]>
5424
- * @since 1.x.x - 2007-05-01
5425
- * @param array $params
5426
- * @param array $defaults
5427
- * @return array
5428
- */
5429
-  function _setParams( $params, $defaults=FALSE ) {
5418
+     * set input (formatted) parameters- component property attributes
5419
+     *
5420
+     * default parameters can be set, if missing
5421
+     *
5422
+     * @author Kjell-Inge Gustafsson <[email protected]>
5423
+     * @since 1.x.x - 2007-05-01
5424
+     * @param array $params
5425
+     * @param array $defaults
5426
+     * @return array
5427
+     */
5428
+    function _setParams( $params, $defaults=FALSE ) {
5430 5429
     if( !is_array( $params))
5431
-      $params = array();
5430
+        $params = array();
5432 5431
     $input = array();
5433 5432
     foreach( $params as $paramKey => $paramValue ) {
5434
-      if( is_array( $paramValue )) {
5433
+        if( is_array( $paramValue )) {
5435 5434
         foreach( $paramValue as $pkey => $pValue ) {
5436
-          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5435
+            if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5437 5436
             $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
5438 5437
         }
5439
-      }
5440
-      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5438
+        }
5439
+        elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5441 5440
         $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5442
-      if( 'VALUE' == strtoupper( $paramKey ))
5441
+        if( 'VALUE' == strtoupper( $paramKey ))
5443 5442
         $input['VALUE']                 = strtoupper( $paramValue );
5444
-      else
5443
+        else
5445 5444
         $input[strtoupper( $paramKey )] = $paramValue;
5446 5445
     }
5447 5446
     if( is_array( $defaults )) {
5448
-      foreach( $defaults as $paramKey => $paramValue ) {
5447
+        foreach( $defaults as $paramKey => $paramValue ) {
5449 5448
         if( !isset( $input[$paramKey] ))
5450
-          $input[$paramKey] = $paramValue;
5451
-      }
5449
+            $input[$paramKey] = $paramValue;
5450
+        }
5452 5451
     }
5453 5452
     return (0 < count( $input )) ? $input : null;
5454
-  }
5453
+    }
5455 5454
 /**
5456
- * step date, return updated date, array and timpstamp
5457
- *
5458
- * @author Kjell-Inge Gustafsson <[email protected]>
5459
- * @since 2.4.16 - 2008-10-18
5460
- * @param array $date, date to step
5461
- * @param int $timestamp
5462
- * @param array $step, default array( 'day' => 1 )
5463
- * @return void
5464
- */
5465
-  function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5455
+     * step date, return updated date, array and timpstamp
5456
+     *
5457
+     * @author Kjell-Inge Gustafsson <[email protected]>
5458
+     * @since 2.4.16 - 2008-10-18
5459
+     * @param array $date, date to step
5460
+     * @param int $timestamp
5461
+     * @param array $step, default array( 'day' => 1 )
5462
+     * @return void
5463
+     */
5464
+    function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5466 5465
     foreach( $step as $stepix => $stepvalue )
5467
-      $date[$stepix] += $stepvalue;
5466
+        $date[$stepix] += $stepvalue;
5468 5467
     $timestamp  = $this->_date2timestamp( $date );
5469 5468
     $date       = $this->_timestamp2date( $timestamp, 6 );
5470 5469
     foreach( $date as $k => $v ) {
5471
-      if( ctype_digit( $v ))
5470
+        if( ctype_digit( $v ))
5472 5471
         $date[$k] = (int) $v;
5473 5472
     }
5474
-  }
5473
+    }
5475 5474
 /**
5476
- * convert timestamp to date array
5477
- *
5478
- * @author Kjell-Inge Gustafsson <[email protected]>
5479
- * @since 2.4.16 - 2008-11-01
5480
- * @param mixed $timestamp
5481
- * @param int $parno
5482
- * @return array
5483
- */
5484
-  function _timestamp2date( $timestamp, $parno=6 ) {
5475
+     * convert timestamp to date array
5476
+     *
5477
+     * @author Kjell-Inge Gustafsson <[email protected]>
5478
+     * @since 2.4.16 - 2008-11-01
5479
+     * @param mixed $timestamp
5480
+     * @param int $parno
5481
+     * @return array
5482
+     */
5483
+    function _timestamp2date( $timestamp, $parno=6 ) {
5485 5484
     if( is_array( $timestamp )) {
5486
-      if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5485
+        if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5487 5486
         $tz = $timestamp['tz'];
5488
-      $timestamp = $timestamp['timestamp'];
5487
+        $timestamp = $timestamp['timestamp'];
5489 5488
     }
5490 5489
     $output = array( 'year'  => date( 'Y', $timestamp )
5491
-                   , 'month' => date( 'm', $timestamp )
5492
-                   , 'day'   => date( 'd', $timestamp ));
5490
+                    , 'month' => date( 'm', $timestamp )
5491
+                    , 'day'   => date( 'd', $timestamp ));
5493 5492
     if( 3 != $parno ) {
5494
-             $output['hour'] =  date( 'H', $timestamp );
5495
-             $output['min']  =  date( 'i', $timestamp );
5496
-             $output['sec']  =  date( 's', $timestamp );
5497
-      if( isset( $tz ))
5493
+                $output['hour'] =  date( 'H', $timestamp );
5494
+                $output['min']  =  date( 'i', $timestamp );
5495
+                $output['sec']  =  date( 's', $timestamp );
5496
+        if( isset( $tz ))
5498 5497
         $output['tz'] = $tz;
5499 5498
     }
5500 5499
     return $output;
5501
-  }
5500
+    }
5502 5501
 /**
5503
- * convert (numeric) local time offset to seconds correcting localtime to GMT
5504
- *
5505
- * @author Kjell-Inge Gustafsson <[email protected]>
5506
- * @since 2.4.16 - 2008-10-19
5507
- * @param string $offset
5508
- * @return integer
5509
- */
5510
-  function _tz2offset( $tz ) {
5502
+     * convert (numeric) local time offset to seconds correcting localtime to GMT
5503
+     *
5504
+     * @author Kjell-Inge Gustafsson <[email protected]>
5505
+     * @since 2.4.16 - 2008-10-19
5506
+     * @param string $offset
5507
+     * @return integer
5508
+     */
5509
+    function _tz2offset( $tz ) {
5511 5510
     $tz           = trim( (string) $tz );
5512 5511
     $offset       = 0;
5513 5512
     if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5514 5513
        ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5515 5514
        (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5516 5515
            (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5517
-      return $offset;
5516
+        return $offset;
5518 5517
     $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5519 5518
     $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5520 5519
     $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
5521 5520
     $offset       = $hours2sec + $min2sec + $sec;
5522 5521
     $offset       = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset;
5523 5522
     return $offset;
5524
-  }
5523
+    }
5525 5524
 /*********************************************************************************/
5526 5525
 /*********************************************************************************/
5527 5526
 /**
@@ -5532,16 +5531,16 @@  discard block
 block discarded – undo
5532 5531
  * @param string $config
5533 5532
  * @return value
5534 5533
  */
5535
-  function getConfig( $config ) {
5534
+    function getConfig( $config ) {
5536 5535
     switch( strtoupper( $config )) {
5537
-      case 'ALLOWEMPTY':
5536
+        case 'ALLOWEMPTY':
5538 5537
         return $this->allowEmpty;
5539 5538
         break;
5540
-      case 'COMPSINFO':
5539
+        case 'COMPSINFO':
5541 5540
         unset( $this->compix );
5542 5541
         $info = array();
5543 5542
         if( isset( $this->components )) {
5544
-          foreach( $this->components as $cix => $component ) {
5543
+            foreach( $this->components as $cix => $component ) {
5545 5544
             if( empty( $component )) continue;
5546 5545
             unset( $component->propix );
5547 5546
             $info[$cix]['ordno'] = $cix + 1;
@@ -5550,26 +5549,26 @@  discard block
 block discarded – undo
5550 5549
             $info[$cix]['props'] = $component->getConfig( 'propinfo' );
5551 5550
             $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
5552 5551
             unset( $component->propix );
5553
-          }
5552
+            }
5554 5553
         }
5555 5554
         return $info;
5556 5555
         break;
5557
-      case 'FORMAT':
5556
+        case 'FORMAT':
5558 5557
         return $this->format;
5559 5558
         break;
5560
-      case 'LANGUAGE':
5559
+        case 'LANGUAGE':
5561 5560
          // get language for calendar component as defined in [RFC 1766]
5562 5561
         return $this->language;
5563 5562
         break;
5564
-      case 'NL':
5563
+        case 'NL':
5565 5564
       case 'NEWLINECHAR':
5566 5565
         return $this->nl;
5567 5566
         break;
5568
-      case 'PROPINFO':
5567
+        case 'PROPINFO':
5569 5568
         $output = array();
5570 5569
         if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5571
-          if( empty( $this->uid['value'] )) $this->_makeuid();
5572
-                                              $output['UID']              = 1;
5570
+            if( empty( $this->uid['value'] )) $this->_makeuid();
5571
+                                                $output['UID']              = 1;
5573 5572
         }
5574 5573
         if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5575 5574
         if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
@@ -5616,51 +5615,51 @@  discard block
 block discarded – undo
5616 5615
         if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
5617 5616
         return $output;
5618 5617
         break;
5619
-      case 'UNIQUE_ID':
5618
+        case 'UNIQUE_ID':
5620 5619
         if( empty( $this->unique_id ))
5621
-          $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
5620
+            $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
5622 5621
         return $this->unique_id;
5623 5622
         break;
5624 5623
     }
5625
-  }
5624
+    }
5626 5625
 /**
5627
- * general component config setting
5628
- *
5629
- * @author Kjell-Inge Gustafsson <[email protected]>
5630
- * @since 2.4.8 - 2008-10-24
5631
- * @param string $config
5632
- * @param string $value
5633
- * @return void
5634
- */
5635
-  function setConfig( $config, $value ) {
5626
+     * general component config setting
5627
+     *
5628
+     * @author Kjell-Inge Gustafsson <[email protected]>
5629
+     * @since 2.4.8 - 2008-10-24
5630
+     * @param string $config
5631
+     * @param string $value
5632
+     * @return void
5633
+     */
5634
+    function setConfig( $config, $value ) {
5636 5635
     $res = FALSE;
5637 5636
     switch( strtoupper( $config )) {
5638
-      case 'ALLOWEMPTY':
5637
+        case 'ALLOWEMPTY':
5639 5638
         $this->allowEmpty = $value;
5640 5639
         $subcfg = array( 'ALLOWEMPTY' => $value );
5641 5640
         $res    = TRUE;
5642 5641
         break;
5643
-      case 'FORMAT':
5642
+        case 'FORMAT':
5644 5643
         $value  = trim( $value );
5645 5644
         $this->format = $value;
5646 5645
         $this->_createFormat();
5647 5646
         $subcfg = array( 'FORMAT' => $value );
5648 5647
         $res    = TRUE;
5649 5648
         break;
5650
-      case 'LANGUAGE':
5649
+        case 'LANGUAGE':
5651 5650
          // set language for calendar component as defined in [RFC 1766]
5652 5651
         $value  = trim( $value );
5653 5652
         $this->language = $value;
5654 5653
         $subcfg = array( 'LANGUAGE' => $value );
5655 5654
         $res    = TRUE;
5656 5655
         break;
5657
-      case 'NL':
5656
+        case 'NL':
5658 5657
       case 'NEWLINECHAR':
5659 5658
         $this->nl = $value;
5660 5659
         $subcfg = array( 'NL' => $value );
5661 5660
         $res    = TRUE;
5662 5661
         break;
5663
-      case 'UNIQUE_ID':
5662
+        case 'UNIQUE_ID':
5664 5663
         $value  = trim( $value );
5665 5664
         $this->unique_id = $value;
5666 5665
         $subcfg = array( 'UNIQUE_ID' => $value );
@@ -5669,17 +5668,17 @@  discard block
 block discarded – undo
5669 5668
     }
5670 5669
     if( !$res ) return FALSE;
5671 5670
     if( isset( $subcfg ) && !empty( $this->components )) {
5672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
5671
+        foreach( $subcfg as $cfgkey => $cfgvalue ) {
5673 5672
         foreach( $this->components as $cix => $component ) {
5674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
5675
-          if( !$res )
5673
+            $res = $component->setConfig( $cfgkey, $cfgvalue );
5674
+            if( !$res )
5676 5675
             break 2;
5677
-          $this->components[$cix] = $component; // PHP4 compliant
5676
+            $this->components[$cix] = $component; // PHP4 compliant
5677
+        }
5678 5678
         }
5679
-      }
5680 5679
     }
5681 5680
     return $res;
5682
-  }
5681
+    }
5683 5682
 /*********************************************************************************/
5684 5683
 /**
5685 5684
  * delete component property value
@@ -5690,257 +5689,257 @@  discard block
 block discarded – undo
5690 5689
  * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5691 5690
  * @return bool, if successfull delete TRUE
5692 5691
  */
5693
-  function deleteProperty( $propName, $propix=FALSE ) {
5692
+    function deleteProperty( $propName, $propix=FALSE ) {
5694 5693
     if( $this->_notExistProp( $propName )) return FALSE;
5695 5694
     $propName = strtoupper( $propName );
5696 5695
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5697 5696
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5698
-      if( !$propix )
5697
+        if( !$propix )
5699 5698
         $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
5700
-      $this->propdelix[$propName] = --$propix;
5699
+        $this->propdelix[$propName] = --$propix;
5701 5700
     }
5702 5701
     $return = FALSE;
5703 5702
     switch( $propName ) {
5704
-      case 'ACTION':
5703
+        case 'ACTION':
5705 5704
         if( !empty( $this->action )) {
5706
-          $this->action = '';
5707
-          $return = TRUE;
5705
+            $this->action = '';
5706
+            $return = TRUE;
5708 5707
         }
5709 5708
         break;
5710
-      case 'ATTACH':
5709
+        case 'ATTACH':
5711 5710
         return $this->deletePropertyM( $this->attach, $propix );
5712 5711
         break;
5713
-      case 'ATTENDEE':
5712
+        case 'ATTENDEE':
5714 5713
         return $this->deletePropertyM( $this->attendee, $propix );
5715 5714
         break;
5716
-      case 'CATEGORIES':
5715
+        case 'CATEGORIES':
5717 5716
         return $this->deletePropertyM( $this->categories, $propix );
5718 5717
         break;
5719
-      case 'CLASS':
5718
+        case 'CLASS':
5720 5719
         if( !empty( $this->class )) {
5721
-          $this->class = '';
5722
-          $return = TRUE;
5720
+            $this->class = '';
5721
+            $return = TRUE;
5723 5722
         }
5724 5723
         break;
5725
-      case 'COMMENT':
5724
+        case 'COMMENT':
5726 5725
         return $this->deletePropertyM( $this->comment, $propix );
5727 5726
         break;
5728
-      case 'COMPLETED':
5727
+        case 'COMPLETED':
5729 5728
         if( !empty( $this->completed )) {
5730
-          $this->completed = '';
5731
-          $return = TRUE;
5729
+            $this->completed = '';
5730
+            $return = TRUE;
5732 5731
         }
5733 5732
         break;
5734
-      case 'CONTACT':
5733
+        case 'CONTACT':
5735 5734
         return $this->deletePropertyM( $this->contact, $propix );
5736 5735
         break;
5737
-      case 'CREATED':
5736
+        case 'CREATED':
5738 5737
         if( !empty( $this->created )) {
5739
-          $this->created = '';
5740
-          $return = TRUE;
5738
+            $this->created = '';
5739
+            $return = TRUE;
5741 5740
         }
5742 5741
         break;
5743
-      case 'DESCRIPTION':
5742
+        case 'DESCRIPTION':
5744 5743
         return $this->deletePropertyM( $this->description, $propix );
5745 5744
         break;
5746
-      case 'DTEND':
5745
+        case 'DTEND':
5747 5746
         if( !empty( $this->dtend )) {
5748
-          $this->dtend = '';
5749
-          $return = TRUE;
5747
+            $this->dtend = '';
5748
+            $return = TRUE;
5750 5749
         }
5751 5750
         break;
5752
-      case 'DTSTAMP':
5751
+        case 'DTSTAMP':
5753 5752
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5754
-          return FALSE;
5753
+            return FALSE;
5755 5754
         if( !empty( $this->dtstamp )) {
5756
-          $this->dtstamp = '';
5757
-          $return = TRUE;
5755
+            $this->dtstamp = '';
5756
+            $return = TRUE;
5758 5757
         }
5759 5758
         break;
5760
-      case 'DTSTART':
5759
+        case 'DTSTART':
5761 5760
         if( !empty( $this->dtstart )) {
5762
-          $this->dtstart = '';
5763
-          $return = TRUE;
5761
+            $this->dtstart = '';
5762
+            $return = TRUE;
5764 5763
         }
5765 5764
         break;
5766
-      case 'DUE':
5765
+        case 'DUE':
5767 5766
         if( !empty( $this->due )) {
5768
-          $this->due = '';
5769
-          $return = TRUE;
5767
+            $this->due = '';
5768
+            $return = TRUE;
5770 5769
         }
5771 5770
         break;
5772
-      case 'DURATION':
5771
+        case 'DURATION':
5773 5772
         if( !empty( $this->duration )) {
5774
-          $this->duration = '';
5775
-          $return = TRUE;
5773
+            $this->duration = '';
5774
+            $return = TRUE;
5776 5775
         }
5777 5776
         break;
5778
-      case 'EXDATE':
5777
+        case 'EXDATE':
5779 5778
         return $this->deletePropertyM( $this->exdate, $propix );
5780 5779
         break;
5781
-      case 'EXRULE':
5780
+        case 'EXRULE':
5782 5781
         return $this->deletePropertyM( $this->exrule, $propix );
5783 5782
         break;
5784
-      case 'FREEBUSY':
5783
+        case 'FREEBUSY':
5785 5784
         return $this->deletePropertyM( $this->freebusy, $propix );
5786 5785
         break;
5787
-      case 'GEO':
5786
+        case 'GEO':
5788 5787
         if( !empty( $this->geo )) {
5789
-          $this->geo = '';
5790
-          $return = TRUE;
5788
+            $this->geo = '';
5789
+            $return = TRUE;
5791 5790
         }
5792 5791
         break;
5793
-      case 'LAST-MODIFIED':
5792
+        case 'LAST-MODIFIED':
5794 5793
         if( !empty( $this->lastmodified )) {
5795
-          $this->lastmodified = '';
5796
-          $return = TRUE;
5794
+            $this->lastmodified = '';
5795
+            $return = TRUE;
5797 5796
         }
5798 5797
         break;
5799
-      case 'LOCATION':
5798
+        case 'LOCATION':
5800 5799
         if( !empty( $this->location )) {
5801
-          $this->location = '';
5802
-          $return = TRUE;
5800
+            $this->location = '';
5801
+            $return = TRUE;
5803 5802
         }
5804 5803
         break;
5805
-      case 'ORGANIZER':
5804
+        case 'ORGANIZER':
5806 5805
         if( !empty( $this->organizer )) {
5807
-          $this->organizer = '';
5808
-          $return = TRUE;
5806
+            $this->organizer = '';
5807
+            $return = TRUE;
5809 5808
         }
5810 5809
         break;
5811
-      case 'PERCENT-COMPLETE':
5810
+        case 'PERCENT-COMPLETE':
5812 5811
         if( !empty( $this->percentcomplete )) {
5813
-          $this->percentcomplete = '';
5814
-          $return = TRUE;
5812
+            $this->percentcomplete = '';
5813
+            $return = TRUE;
5815 5814
         }
5816 5815
         break;
5817
-      case 'PRIORITY':
5816
+        case 'PRIORITY':
5818 5817
         if( !empty( $this->priority )) {
5819
-          $this->priority = '';
5820
-          $return = TRUE;
5818
+            $this->priority = '';
5819
+            $return = TRUE;
5821 5820
         }
5822 5821
         break;
5823
-      case 'RDATE':
5822
+        case 'RDATE':
5824 5823
         return $this->deletePropertyM( $this->rdate, $propix );
5825 5824
         break;
5826
-      case 'RECURRENCE-ID':
5825
+        case 'RECURRENCE-ID':
5827 5826
         if( !empty( $this->recurrenceid )) {
5828
-          $this->recurrenceid = '';
5829
-          $return = TRUE;
5827
+            $this->recurrenceid = '';
5828
+            $return = TRUE;
5830 5829
         }
5831 5830
         break;
5832
-      case 'RELATED-TO':
5831
+        case 'RELATED-TO':
5833 5832
         return $this->deletePropertyM( $this->relatedto, $propix );
5834 5833
         break;
5835
-      case 'REPEAT':
5834
+        case 'REPEAT':
5836 5835
         if( !empty( $this->repeat )) {
5837
-          $this->repeat = '';
5838
-          $return = TRUE;
5836
+            $this->repeat = '';
5837
+            $return = TRUE;
5839 5838
         }
5840 5839
         break;
5841
-      case 'REQUEST-STATUS':
5840
+        case 'REQUEST-STATUS':
5842 5841
         return $this->deletePropertyM( $this->requeststatus, $propix );
5843 5842
         break;
5844
-      case 'RESOURCES':
5843
+        case 'RESOURCES':
5845 5844
         return $this->deletePropertyM( $this->resources, $propix );
5846 5845
         break;
5847
-      case 'RRULE':
5846
+        case 'RRULE':
5848 5847
         return $this->deletePropertyM( $this->rrule, $propix );
5849 5848
         break;
5850
-      case 'SEQUENCE':
5849
+        case 'SEQUENCE':
5851 5850
         if( !empty( $this->sequence )) {
5852
-          $this->sequence = '';
5853
-          $return = TRUE;
5851
+            $this->sequence = '';
5852
+            $return = TRUE;
5854 5853
         }
5855 5854
         break;
5856
-      case 'STATUS':
5855
+        case 'STATUS':
5857 5856
         if( !empty( $this->status )) {
5858
-          $this->status = '';
5859
-          $return = TRUE;
5857
+            $this->status = '';
5858
+            $return = TRUE;
5860 5859
         }
5861 5860
         break;
5862
-      case 'SUMMARY':
5861
+        case 'SUMMARY':
5863 5862
         if( !empty( $this->summary )) {
5864
-          $this->summary = '';
5865
-          $return = TRUE;
5863
+            $this->summary = '';
5864
+            $return = TRUE;
5866 5865
         }
5867 5866
         break;
5868
-      case 'TRANSP':
5867
+        case 'TRANSP':
5869 5868
         if( !empty( $this->transp )) {
5870
-          $this->transp = '';
5871
-          $return = TRUE;
5869
+            $this->transp = '';
5870
+            $return = TRUE;
5872 5871
         }
5873 5872
         break;
5874
-      case 'TRIGGER':
5873
+        case 'TRIGGER':
5875 5874
         if( !empty( $this->trigger )) {
5876
-          $this->trigger = '';
5877
-          $return = TRUE;
5875
+            $this->trigger = '';
5876
+            $return = TRUE;
5878 5877
         }
5879 5878
         break;
5880
-      case 'TZID':
5879
+        case 'TZID':
5881 5880
         if( !empty( $this->tzid )) {
5882
-          $this->tzid = '';
5883
-          $return = TRUE;
5881
+            $this->tzid = '';
5882
+            $return = TRUE;
5884 5883
         }
5885 5884
         break;
5886
-      case 'TZNAME':
5885
+        case 'TZNAME':
5887 5886
         return $this->deletePropertyM( $this->tzname, $propix );
5888 5887
         break;
5889
-      case 'TZOFFSETFROM':
5888
+        case 'TZOFFSETFROM':
5890 5889
         if( !empty( $this->tzoffsetfrom )) {
5891
-          $this->tzoffsetfrom = '';
5892
-          $return = TRUE;
5890
+            $this->tzoffsetfrom = '';
5891
+            $return = TRUE;
5893 5892
         }
5894 5893
         break;
5895
-      case 'TZOFFSETTO':
5894
+        case 'TZOFFSETTO':
5896 5895
         if( !empty( $this->tzoffsetto )) {
5897
-          $this->tzoffsetto = '';
5898
-          $return = TRUE;
5896
+            $this->tzoffsetto = '';
5897
+            $return = TRUE;
5899 5898
         }
5900 5899
         break;
5901
-      case 'TZURL':
5900
+        case 'TZURL':
5902 5901
         if( !empty( $this->tzurl )) {
5903
-          $this->tzurl = '';
5904
-          $return = TRUE;
5902
+            $this->tzurl = '';
5903
+            $return = TRUE;
5905 5904
         }
5906 5905
         break;
5907
-      case 'UID':
5906
+        case 'UID':
5908 5907
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5909
-          return FALSE;
5908
+            return FALSE;
5910 5909
         if( !empty( $this->uid )) {
5911
-          $this->uid = '';
5912
-          $return = TRUE;
5910
+            $this->uid = '';
5911
+            $return = TRUE;
5913 5912
         }
5914 5913
         break;
5915
-      case 'URL':
5914
+        case 'URL':
5916 5915
         if( !empty( $this->url )) {
5917
-          $this->url = '';
5918
-          $return = TRUE;
5916
+            $this->url = '';
5917
+            $return = TRUE;
5919 5918
         }
5920 5919
         break;
5921
-      default:
5920
+        default:
5922 5921
         $reduced = '';
5923 5922
         if( $propName != 'X-PROP' ) {
5924
-          if( !isset( $this->xprop[$propName] )) return FALSE;
5925
-          foreach( $this->xprop as $k => $a ) {
5923
+            if( !isset( $this->xprop[$propName] )) return FALSE;
5924
+            foreach( $this->xprop as $k => $a ) {
5926 5925
             if(( $k != $propName ) && !empty( $a ))
5927
-              $reduced[$k] = $a;
5928
-          }
5926
+                $reduced[$k] = $a;
5927
+            }
5929 5928
         }
5930 5929
         else {
5931
-          if( count( $this->xprop ) <= $propix )  return FALSE;
5932
-          $xpropno = 0;
5933
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5930
+            if( count( $this->xprop ) <= $propix )  return FALSE;
5931
+            $xpropno = 0;
5932
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5934 5933
             if( $propix != $xpropno )
5935
-              $reduced[$xpropkey] = $xpropvalue;
5934
+                $reduced[$xpropkey] = $xpropvalue;
5936 5935
             $xpropno++;
5937
-          }
5936
+            }
5938 5937
         }
5939 5938
         $this->xprop = $reduced;
5940 5939
         return TRUE;
5941 5940
     }
5942 5941
     return $return;
5943
-  }
5942
+    }
5944 5943
 /*********************************************************************************/
5945 5944
 /**
5946 5945
  * delete component property value, fixing components with multiple occurencies
@@ -5951,324 +5950,324 @@  discard block
 block discarded – undo
5951 5950
  * @param int @propix, default 0
5952 5951
  * @return bool TRUE
5953 5952
  */
5954
-  function deletePropertyM( & $multiprop, $propix=0 ) {
5953
+    function deletePropertyM( & $multiprop, $propix=0 ) {
5955 5954
     if( !isset( $multiprop[$propix])) return FALSE;
5956 5955
     unset( $multiprop[$propix] );
5957 5956
     if( empty( $multiprop )) $multiprop = '';
5958 5957
     return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5959
-  }
5958
+    }
5960 5959
 /**
5961
- * get component property value/params
5962
- *
5963
- * if property has multiply values, consequtive function calls are needed
5964
- *
5965
- * @author Kjell-Inge Gustafsson <[email protected]>
5966
- * @since 2.5.1 - 2008-11-02
5967
- * @param string $propName, optional
5968
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5969
- * @param bool $inclParam=FALSE
5970
- * @param bool $specform=FALSE
5971
- * @return mixed
5972
- */
5973
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5960
+     * get component property value/params
5961
+     *
5962
+     * if property has multiply values, consequtive function calls are needed
5963
+     *
5964
+     * @author Kjell-Inge Gustafsson <[email protected]>
5965
+     * @since 2.5.1 - 2008-11-02
5966
+     * @param string $propName, optional
5967
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5968
+     * @param bool $inclParam=FALSE
5969
+     * @param bool $specform=FALSE
5970
+     * @return mixed
5971
+     */
5972
+    function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5974 5973
     if( $this->_notExistProp( $propName )) return FALSE;
5975 5974
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
5976 5975
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5977 5976
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5978
-      if( !$propix )
5977
+        if( !$propix )
5979 5978
         $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
5980
-      $this->propix[$propName] = --$propix;
5979
+        $this->propix[$propName] = --$propix;
5981 5980
     }
5982 5981
     switch( $propName ) {
5983
-      case 'ACTION':
5982
+        case 'ACTION':
5984 5983
         if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
5985 5984
         break;
5986
-      case 'ATTACH':
5985
+        case 'ATTACH':
5987 5986
         if( !isset( $this->attach[$propix] )) return FALSE;
5988 5987
         return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5989 5988
         break;
5990
-      case 'ATTENDEE':
5989
+        case 'ATTENDEE':
5991 5990
         if( !isset( $this->attendee[$propix] )) return FALSE;
5992 5991
         return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5993 5992
         break;
5994
-      case 'CATEGORIES':
5993
+        case 'CATEGORIES':
5995 5994
         if( !isset( $this->categories[$propix] )) return FALSE;
5996 5995
         return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5997 5996
         break;
5998
-      case 'CLASS':
5997
+        case 'CLASS':
5999 5998
         if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
6000 5999
         break;
6001
-      case 'COMMENT':
6000
+        case 'COMMENT':
6002 6001
         if( !isset( $this->comment[$propix] )) return FALSE;
6003 6002
         return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6004 6003
         break;
6005
-      case 'COMPLETED':
6004
+        case 'COMPLETED':
6006 6005
         if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6007 6006
         break;
6008
-      case 'CONTACT':
6007
+        case 'CONTACT':
6009 6008
         if( !isset( $this->contact[$propix] )) return FALSE;
6010 6009
         return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6011 6010
         break;
6012
-      case 'CREATED':
6011
+        case 'CREATED':
6013 6012
         if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6014 6013
         break;
6015
-      case 'DESCRIPTION':
6014
+        case 'DESCRIPTION':
6016 6015
         if( !isset( $this->description[$propix] )) return FALSE;
6017 6016
         return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6018 6017
         break;
6019
-      case 'DTEND':
6018
+        case 'DTEND':
6020 6019
         if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6021 6020
         break;
6022
-      case 'DTSTAMP':
6021
+        case 'DTSTAMP':
6023 6022
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6024
-          return;
6023
+            return;
6025 6024
         if( !isset( $this->dtstamp['value'] ))
6026
-          $this->_makeDtstamp();
6025
+            $this->_makeDtstamp();
6027 6026
         return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6028 6027
         break;
6029
-      case 'DTSTART':
6028
+        case 'DTSTART':
6030 6029
         if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6031 6030
         break;
6032
-      case 'DUE':
6031
+        case 'DUE':
6033 6032
         if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6034 6033
         break;
6035
-      case 'DURATION':
6034
+        case 'DURATION':
6036 6035
         if( !isset( $this->duration['value'] )) return FALSE;
6037 6036
         $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6038 6037
         return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6039 6038
         break;
6040
-      case 'EXDATE':
6039
+        case 'EXDATE':
6041 6040
         if( !isset( $this->exdate[$propix] )) return FALSE;
6042 6041
         return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6043 6042
         break;
6044
-      case 'EXRULE':
6043
+        case 'EXRULE':
6045 6044
         if( !isset( $this->exrule[$propix] )) return FALSE;
6046 6045
         return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6047 6046
         break;
6048
-      case 'FREEBUSY':
6047
+        case 'FREEBUSY':
6049 6048
         if( !isset( $this->freebusy[$propix] )) return FALSE;
6050 6049
         return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6051 6050
         break;
6052
-      case 'GEO':
6051
+        case 'GEO':
6053 6052
         if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6054 6053
         break;
6055
-      case 'LAST-MODIFIED':
6054
+        case 'LAST-MODIFIED':
6056 6055
         if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6057 6056
         break;
6058
-      case 'LOCATION':
6057
+        case 'LOCATION':
6059 6058
         if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6060 6059
         break;
6061
-      case 'ORGANIZER':
6060
+        case 'ORGANIZER':
6062 6061
         if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6063 6062
         break;
6064
-      case 'PERCENT-COMPLETE':
6063
+        case 'PERCENT-COMPLETE':
6065 6064
         if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6066 6065
         break;
6067
-      case 'PRIORITY':
6066
+        case 'PRIORITY':
6068 6067
         if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6069 6068
         break;
6070
-      case 'RDATE':
6069
+        case 'RDATE':
6071 6070
         if( !isset( $this->rdate[$propix] )) return FALSE;
6072 6071
         return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6073 6072
         break;
6074
-      case 'RECURRENCE-ID':
6073
+        case 'RECURRENCE-ID':
6075 6074
         if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6076 6075
         break;
6077
-      case 'RELATED-TO':
6076
+        case 'RELATED-TO':
6078 6077
         if( !isset( $this->relatedto[$propix] )) return FALSE;
6079 6078
         return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6080 6079
         break;
6081
-      case 'REPEAT':
6080
+        case 'REPEAT':
6082 6081
         if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6083 6082
         break;
6084
-      case 'REQUEST-STATUS':
6083
+        case 'REQUEST-STATUS':
6085 6084
         if( !isset( $this->requeststatus[$propix] )) return FALSE;
6086 6085
         return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6087 6086
         break;
6088
-      case 'RESOURCES':
6087
+        case 'RESOURCES':
6089 6088
         if( !isset( $this->resources[$propix] )) return FALSE;
6090 6089
         return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6091 6090
         break;
6092
-      case 'RRULE':
6091
+        case 'RRULE':
6093 6092
         if( !isset( $this->rrule[$propix] )) return FALSE;
6094 6093
         return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6095 6094
         break;
6096
-      case 'SEQUENCE':
6095
+        case 'SEQUENCE':
6097 6096
         if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6098 6097
         break;
6099
-      case 'STATUS':
6098
+        case 'STATUS':
6100 6099
         if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6101 6100
         break;
6102
-      case 'SUMMARY':
6101
+        case 'SUMMARY':
6103 6102
         if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6104 6103
         break;
6105
-      case 'TRANSP':
6104
+        case 'TRANSP':
6106 6105
         if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6107 6106
         break;
6108
-      case 'TRIGGER':
6107
+        case 'TRIGGER':
6109 6108
         if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6110 6109
         break;
6111
-      case 'TZID':
6110
+        case 'TZID':
6112 6111
         if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6113 6112
         break;
6114
-      case 'TZNAME':
6113
+        case 'TZNAME':
6115 6114
         if( !isset( $this->tzname[$propix] )) return FALSE;
6116 6115
         return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6117 6116
         break;
6118
-      case 'TZOFFSETFROM':
6117
+        case 'TZOFFSETFROM':
6119 6118
         if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6120 6119
         break;
6121
-      case 'TZOFFSETTO':
6120
+        case 'TZOFFSETTO':
6122 6121
         if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6123 6122
         break;
6124
-      case 'TZURL':
6123
+        case 'TZURL':
6125 6124
         if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6126 6125
         break;
6127
-      case 'UID':
6126
+        case 'UID':
6128 6127
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6129
-          return FALSE;
6128
+            return FALSE;
6130 6129
         if( empty( $this->uid['value'] ))
6131
-          $this->_makeuid();
6130
+            $this->_makeuid();
6132 6131
         return ( $inclParam ) ? $this->uid : $this->uid['value'];
6133 6132
         break;
6134
-      case 'URL':
6133
+        case 'URL':
6135 6134
         if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
6136 6135
         break;
6137
-      default:
6136
+        default:
6138 6137
         if( $propName != 'X-PROP' ) {
6139
-          if( !isset( $this->xprop[$propName] )) return FALSE;
6140
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6138
+            if( !isset( $this->xprop[$propName] )) return FALSE;
6139
+            return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6141 6140
                                 : array( $propName, $this->xprop[$propName]['value'] );
6142 6141
         }
6143 6142
         else {
6144
-          if( empty( $this->xprop )) return FALSE;
6145
-          $xpropno = 0;
6146
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6143
+            if( empty( $this->xprop )) return FALSE;
6144
+            $xpropno = 0;
6145
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6147 6146
             if( $propix == $xpropno )
6148
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6147
+                return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6149 6148
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6150 6149
             else
6151
-              $xpropno++;
6152
-          }
6153
-          return FALSE; // not found ??
6150
+                $xpropno++;
6151
+            }
6152
+            return FALSE; // not found ??
6154 6153
         }
6155 6154
     }
6156 6155
     return FALSE;
6157
-  }
6156
+    }
6158 6157
 /**
6159
- * general component property setting
6160
- *
6161
- * @author Kjell-Inge Gustafsson <[email protected]>
6162
- * @since 2.5.1 - 2008-11-05
6163
- * @param mixed $args variable number of function arguments,
6164
- *                    first argument is ALWAYS component name,
6165
- *                    second ALWAYS component value!
6166
- * @return void
6167
- */
6168
-  function setProperty() {
6158
+     * general component property setting
6159
+     *
6160
+     * @author Kjell-Inge Gustafsson <[email protected]>
6161
+     * @since 2.5.1 - 2008-11-05
6162
+     * @param mixed $args variable number of function arguments,
6163
+     *                    first argument is ALWAYS component name,
6164
+     *                    second ALWAYS component value!
6165
+     * @return void
6166
+     */
6167
+    function setProperty() {
6169 6168
     $numargs    = func_num_args();
6170 6169
     if( 1 > $numargs ) return FALSE;
6171 6170
     $arglist    = func_get_args();
6172 6171
     if( $this->_notExistProp( $arglist[0] )) return FALSE;
6173 6172
     if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
6174
-      return FALSE;
6173
+        return FALSE;
6175 6174
     $arglist[0] = strtoupper( $arglist[0] );
6176 6175
     for( $argix=$numargs; $argix < 12; $argix++ ) {
6177
-      if( !isset( $arglist[$argix] ))
6176
+        if( !isset( $arglist[$argix] ))
6178 6177
         $arglist[$argix] = null;
6179 6178
     }
6180 6179
     switch( $arglist[0] ) {
6181
-      case 'ACTION':
6180
+        case 'ACTION':
6182 6181
         return $this->setAction( $arglist[1], $arglist[2] );
6183
-      case 'ATTACH':
6182
+        case 'ATTACH':
6184 6183
         return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] );
6185
-      case 'ATTENDEE':
6184
+        case 'ATTENDEE':
6186 6185
         return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] );
6187
-      case 'CATEGORIES':
6186
+        case 'CATEGORIES':
6188 6187
         return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] );
6189
-      case 'CLASS':
6188
+        case 'CLASS':
6190 6189
         return $this->setClass( $arglist[1], $arglist[2] );
6191
-      case 'COMMENT':
6190
+        case 'COMMENT':
6192 6191
         return $this->setComment( $arglist[1], $arglist[2], $arglist[3] );
6193
-      case 'COMPLETED':
6192
+        case 'COMPLETED':
6194 6193
         return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6195
-      case 'CONTACT':
6194
+        case 'CONTACT':
6196 6195
         return $this->setContact( $arglist[1], $arglist[2], $arglist[3] );
6197
-      case 'CREATED':
6196
+        case 'CREATED':
6198 6197
         return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6199
-      case 'DESCRIPTION':
6198
+        case 'DESCRIPTION':
6200 6199
         return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] );
6201
-      case 'DTEND':
6200
+        case 'DTEND':
6202 6201
         return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6203
-      case 'DTSTAMP':
6202
+        case 'DTSTAMP':
6204 6203
         return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6205
-      case 'DTSTART':
6204
+        case 'DTSTART':
6206 6205
         return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6207
-      case 'DUE':
6206
+        case 'DUE':
6208 6207
         return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6209
-      case 'DURATION':
6208
+        case 'DURATION':
6210 6209
         return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] );
6211
-      case 'EXDATE':
6210
+        case 'EXDATE':
6212 6211
         return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] );
6213
-      case 'EXRULE':
6212
+        case 'EXRULE':
6214 6213
         return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] );
6215
-      case 'FREEBUSY':
6214
+        case 'FREEBUSY':
6216 6215
         return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] );
6217
-      case 'GEO':
6216
+        case 'GEO':
6218 6217
         return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] );
6219
-      case 'LAST-MODIFIED':
6218
+        case 'LAST-MODIFIED':
6220 6219
         return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6221
-      case 'LOCATION':
6220
+        case 'LOCATION':
6222 6221
         return $this->setLocation( $arglist[1], $arglist[2] );
6223
-      case 'ORGANIZER':
6222
+        case 'ORGANIZER':
6224 6223
         return $this->setOrganizer( $arglist[1], $arglist[2] );
6225
-      case 'PERCENT-COMPLETE':
6224
+        case 'PERCENT-COMPLETE':
6226 6225
         return $this->setPercentComplete( $arglist[1], $arglist[2] );
6227
-      case 'PRIORITY':
6226
+        case 'PRIORITY':
6228 6227
         return $this->setPriority( $arglist[1], $arglist[2] );
6229
-      case 'RDATE':
6228
+        case 'RDATE':
6230 6229
         return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] );
6231
-      case 'RECURRENCE-ID':
6230
+        case 'RECURRENCE-ID':
6232 6231
        return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6233
-      case 'RELATED-TO':
6232
+        case 'RELATED-TO':
6234 6233
         return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] );
6235
-      case 'REPEAT':
6234
+        case 'REPEAT':
6236 6235
         return $this->setRepeat( $arglist[1], $arglist[2] );
6237
-      case 'REQUEST-STATUS':
6236
+        case 'REQUEST-STATUS':
6238 6237
         return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] );
6239
-      case 'RESOURCES':
6238
+        case 'RESOURCES':
6240 6239
         return $this->setResources( $arglist[1], $arglist[2], $arglist[3] );
6241
-      case 'RRULE':
6240
+        case 'RRULE':
6242 6241
         return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] );
6243
-      case 'SEQUENCE':
6242
+        case 'SEQUENCE':
6244 6243
         return $this->setSequence( $arglist[1], $arglist[2] );
6245
-      case 'STATUS':
6244
+        case 'STATUS':
6246 6245
         return $this->setStatus( $arglist[1], $arglist[2] );
6247
-      case 'SUMMARY':
6246
+        case 'SUMMARY':
6248 6247
         return $this->setSummary( $arglist[1], $arglist[2] );
6249
-      case 'TRANSP':
6248
+        case 'TRANSP':
6250 6249
         return $this->setTransp( $arglist[1], $arglist[2] );
6251
-      case 'TRIGGER':
6250
+        case 'TRIGGER':
6252 6251
         return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] );
6253
-      case 'TZID':
6252
+        case 'TZID':
6254 6253
         return $this->setTzid( $arglist[1], $arglist[2] );
6255
-      case 'TZNAME':
6254
+        case 'TZNAME':
6256 6255
         return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] );
6257
-      case 'TZOFFSETFROM':
6256
+        case 'TZOFFSETFROM':
6258 6257
         return $this->setTzoffsetfrom( $arglist[1], $arglist[2] );
6259
-      case 'TZOFFSETTO':
6258
+        case 'TZOFFSETTO':
6260 6259
         return $this->setTzoffsetto( $arglist[1], $arglist[2] );
6261
-      case 'TZURL':
6260
+        case 'TZURL':
6262 6261
         return $this->setTzurl( $arglist[1], $arglist[2] );
6263
-      case 'UID':
6262
+        case 'UID':
6264 6263
         return $this->setUid( $arglist[1], $arglist[2] );
6265
-      case 'URL':
6264
+        case 'URL':
6266 6265
         return $this->setUrl( $arglist[1], $arglist[2] );
6267
-      default:
6266
+        default:
6268 6267
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
6269 6268
     }
6270 6269
     return FALSE;
6271
-  }
6270
+    }
6272 6271
 /*********************************************************************************/
6273 6272
 /**
6274 6273
  * parse component unparsed data into properties
@@ -6279,153 +6278,153 @@  discard block
 block discarded – undo
6279 6278
  * @return bool FALSE if error occurs during parsing
6280 6279
  *
6281 6280
  */
6282
-  function parse( $unparsedtext=null ) {
6281
+    function parse( $unparsedtext=null ) {
6283 6282
     if( $unparsedtext ) {
6284
-      $this->unparsed = array();
6285
-      if( is_array( $unparsedtext )) {
6283
+        $this->unparsed = array();
6284
+        if( is_array( $unparsedtext )) {
6286 6285
         $comp = & $this;
6287 6286
         foreach ( $unparsedtext as $line ) {
6288
-          if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) {
6287
+            if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) {
6289 6288
             $this->setComponent( $comp );
6290 6289
             $comp =  & $this;
6291 6290
             continue;
6292
-          }
6293
-          elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6291
+            }
6292
+            elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6294 6293
             $comp = new valarm();
6295 6294
             continue;
6296
-          }
6297
-          else
6295
+            }
6296
+            else
6298 6297
             $comp->unparsed[] = $line;
6299 6298
         }
6300
-      }
6301
-      else
6299
+        }
6300
+        else
6302 6301
         $this->unparsed = array( trim( $unparsedtext ));
6303 6302
     }
6304 6303
     elseif( !isset( $this->unparsed ))
6305
-      $this->unparsed = array();
6304
+        $this->unparsed = array();
6306 6305
             /* concatenate property values spread over several lines */
6307 6306
     $lastix    = -1;
6308 6307
     $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
6309
-                      , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart'
6310
-                      , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo'
6311
-                      , 'last-modified', 'location', 'organizer', 'percent-complete'
6312
-                      , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat'
6313
-                      , 'request-status', 'resources', 'rrule', 'sequence', 'status'
6314
-                      , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom'
6315
-                      , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' );
6308
+                        , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart'
6309
+                        , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo'
6310
+                        , 'last-modified', 'location', 'organizer', 'percent-complete'
6311
+                        , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat'
6312
+                        , 'request-status', 'resources', 'rrule', 'sequence', 'status'
6313
+                        , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom'
6314
+                        , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' );
6316 6315
     $proprows  = array();
6317 6316
     foreach( $this->unparsed as $line ) {
6318
-      $newProp = FALSE;
6319
-      foreach ( $propnames as $propname ) {
6317
+        $newProp = FALSE;
6318
+        foreach ( $propnames as $propname ) {
6320 6319
         if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
6321
-          $newProp = TRUE;
6322
-          break;
6320
+            $newProp = TRUE;
6321
+            break;
6323 6322
         }
6324
-      }
6325
-      if( $newProp ) {
6323
+        }
6324
+        if( $newProp ) {
6326 6325
         $newProp = FALSE;
6327 6326
         $lastix++;
6328 6327
         $proprows[$lastix]  = $line;
6329
-      }
6330
-      else {
6328
+        }
6329
+        else {
6331 6330
             /* remove line breaks */
6332 6331
         if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6333 6332
            (  ' ' == substr( $line, 0, 1 ))) {
6334
-          $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
6335
-          $line = substr( $line, 1 );
6333
+            $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
6334
+            $line = substr( $line, 1 );
6336 6335
         }
6337 6336
         $proprows[$lastix] .= $line;
6338
-      }
6337
+        }
6339 6338
     }
6340 6339
             /* parse each property 'line' */
6341 6340
     foreach( $proprows as $line ) {
6342
-      $line = str_replace( "\n ", '', $line );
6343
-      if( '\n' == substr( $line, -2 ))
6341
+        $line = str_replace( "\n ", '', $line );
6342
+        if( '\n' == substr( $line, -2 ))
6344 6343
         $line = substr( $line, 0, strlen( $line ) - 2 );
6345 6344
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6346
-      $cix = $propname = null;
6347
-      for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6345
+        $cix = $propname = null;
6346
+        for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6348 6347
         if( in_array( $line{$cix}, array( ':', ';' )))
6349
-          break;
6348
+            break;
6350 6349
         else {
6351
-          $propname .= $line{$cix};
6350
+            $propname .= $line{$cix};
6352 6351
         }
6353
-      }
6354
-      if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) {
6352
+        }
6353
+        if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) {
6355 6354
         $propname2 = $propname;
6356 6355
         $propname  = 'X-';
6357
-      }
6356
+        }
6358 6357
             /* rest of the line is opt.params and value */
6359
-      $line = substr( $line, $cix );
6358
+        $line = substr( $line, $cix );
6360 6359
             /* separate attributes from value */
6361
-      $attr   = array();
6362
-      $attrix = -1;
6363
-      $strlen = strlen( $line );
6364
-      for( $cix=0; $cix < $strlen; $cix++ ) {
6360
+        $attr   = array();
6361
+        $attrix = -1;
6362
+        $strlen = strlen( $line );
6363
+        for( $cix=0; $cix < $strlen; $cix++ ) {
6365 6364
         if((       ':'   == $line{$cix} )             &&
6366 6365
                  ( '://' != substr( $line, $cix, 3 )) &&
6367 6366
            ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
6368
-          $attrEnd = TRUE;
6369
-          if(( $cix < ( $strlen - 4 )) &&
6367
+            $attrEnd = TRUE;
6368
+            if(( $cix < ( $strlen - 4 )) &&
6370 6369
                ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
6371 6370
             for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
6372
-              if( '://' == substr( $line, $c2ix - 2, 3 )) {
6371
+                if( '://' == substr( $line, $c2ix - 2, 3 )) {
6373 6372
                 $attrEnd = FALSE;
6374 6373
                 break; // an URI with a portnr!!
6375
-              }
6374
+                }
6376 6375
             }
6377
-          }
6378
-          if( $attrEnd) {
6376
+            }
6377
+            if( $attrEnd) {
6379 6378
             $line = substr( $line, $cix + 1 );
6380 6379
             break;
6381
-          }
6380
+            }
6382 6381
         }
6383 6382
         if( ';' == $line{$cix} )
6384
-          $attr[++$attrix] = null;
6383
+            $attr[++$attrix] = null;
6385 6384
         else
6386
-          $attr[$attrix] .= $line{$cix};
6387
-      }
6385
+            $attr[$attrix] .= $line{$cix};
6386
+        }
6388 6387
             /* make attributes in array format */
6389
-      $propattr = array();
6390
-      foreach( $attr as $attribute ) {
6388
+        $propattr = array();
6389
+        foreach( $attr as $attribute ) {
6391 6390
         $attrsplit = explode( '=', $attribute, 2 );
6392 6391
         if( 1 < count( $attrsplit ))
6393
-          $propattr[$attrsplit[0]] = $attrsplit[1];
6392
+            $propattr[$attrsplit[0]] = $attrsplit[1];
6394 6393
         else
6395
-          $propattr[] = $attribute;
6396
-      }
6394
+            $propattr[] = $attribute;
6395
+        }
6397 6396
             /* call setProperty( $propname.. . */
6398
-      switch( $propname ) {
6397
+        switch( $propname ) {
6399 6398
         case 'ATTENDEE':
6400 6399
           foreach( $propattr as $pix => $attr ) {
6401 6400
             $attr2 = explode( ',', $attr );
6402
-              if( 1 < count( $attr2 ))
6401
+                if( 1 < count( $attr2 ))
6403 6402
                 $propattr[$pix] = $attr2;
6404
-          }
6405
-          $this->setProperty( $propname, $line, $propattr );
6406
-          break;
6403
+            }
6404
+            $this->setProperty( $propname, $line, $propattr );
6405
+            break;
6407 6406
         case 'CATEGORIES':
6408 6407
         case 'RESOURCES':
6409 6408
           if( FALSE !== strpos( $line, ',' )) {
6410 6409
             $content  = explode( ',', $line );
6411 6410
             $clen     = count( $content );
6412 6411
             for( $cix = 0; $cix < $clen; $cix++ ) {
6413
-              if( "\\" == substr($content[$cix], -1)) {
6412
+                if( "\\" == substr($content[$cix], -1)) {
6414 6413
                 $content[$cix] .= ','.$content[$cix + 1];
6415 6414
                 unset($content[$cix + 1]);
6416 6415
                 $cix++;
6417
-              }
6416
+                }
6418 6417
             }
6419 6418
             if( 1 < count( $content )) {
6420
-              $content = array_values( $content );
6421
-              foreach( $content as $cix => $contentPart )
6419
+                $content = array_values( $content );
6420
+                foreach( $content as $cix => $contentPart )
6422 6421
                 $content[$cix] = $this->_strunrep( $contentPart );
6423
-              $this->setProperty( $propname, $content, $propattr );
6424
-              break;
6422
+                $this->setProperty( $propname, $content, $propattr );
6423
+                break;
6425 6424
             }
6426 6425
             else
6427
-              $line = reset( $content );
6428
-          }
6426
+                $line = reset( $content );
6427
+            }
6429 6428
         case 'X-':
6430 6429
           $propname = ( isset( $propname2 )) ? $propname2 : $propname;
6431 6430
         case 'COMMENT':
@@ -6435,125 +6434,125 @@  discard block
 block discarded – undo
6435 6434
         case 'SUMMARY':
6436 6435
           if( empty( $line ))
6437 6436
             $propattr = null;
6438
-          $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6439
-          unset( $propname2 );
6440
-          break;
6437
+            $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6438
+            unset( $propname2 );
6439
+            break;
6441 6440
         case 'REQUEST-STATUS':
6442 6441
           $values    = explode( ';', $line, 3 );
6443
-          $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] );
6444
-          $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] );
6445
-          $this->setProperty( $propname
6442
+            $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] );
6443
+            $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] );
6444
+            $this->setProperty( $propname
6446 6445
                             , $values[0]  // statcode
6447 6446
                             , $values[1]  // statdesc
6448 6447
                             , $values[2]  // extdata
6449 6448
                             , $propattr );
6450
-          break;
6449
+            break;
6451 6450
         case 'FREEBUSY':
6452 6451
           $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing
6453
-          unset( $propattr['FBTYPE'] );
6454
-          $values = explode( ',', $line );
6455
-          foreach( $values as $vix => $value ) {
6452
+            unset( $propattr['FBTYPE'] );
6453
+            $values = explode( ',', $line );
6454
+            foreach( $values as $vix => $value ) {
6456 6455
             $value2 = explode( '/', $value );
6457 6456
             if( 1 < count( $value2 ))
6458
-              $values[$vix] = $value2;
6459
-          }
6460
-          $this->setProperty( $propname, $fbtype, $values, $propattr );
6461
-          break;
6457
+                $values[$vix] = $value2;
6458
+            }
6459
+            $this->setProperty( $propname, $fbtype, $values, $propattr );
6460
+            break;
6462 6461
         case 'GEO':
6463 6462
           $value = explode( ';', $line, 2 );
6464
-          if( 2 > count( $value ))
6463
+            if( 2 > count( $value ))
6465 6464
             $value[1] = null;
6466
-          $this->setProperty( $propname, $value[0], $value[1], $propattr );
6467
-          break;
6465
+            $this->setProperty( $propname, $value[0], $value[1], $propattr );
6466
+            break;
6468 6467
         case 'EXDATE':
6469 6468
           $values = ( !empty( $line )) ? explode( ',', $line ) : null;
6470
-          $this->setProperty( $propname, $values, $propattr );
6471
-          break;
6469
+            $this->setProperty( $propname, $values, $propattr );
6470
+            break;
6472 6471
         case 'RDATE':
6473 6472
           if( empty( $line )) {
6474 6473
             $this->setProperty( $propname, $line, $propattr );
6475 6474
             break;
6476
-          }
6477
-          $values = explode( ',', $line );
6478
-          foreach( $values as $vix => $value ) {
6475
+            }
6476
+            $values = explode( ',', $line );
6477
+            foreach( $values as $vix => $value ) {
6479 6478
             $value2 = explode( '/', $value );
6480 6479
             if( 1 < count( $value2 ))
6481
-              $values[$vix] = $value2;
6482
-          }
6483
-          $this->setProperty( $propname, $values, $propattr );
6484
-          break;
6480
+                $values[$vix] = $value2;
6481
+            }
6482
+            $this->setProperty( $propname, $values, $propattr );
6483
+            break;
6485 6484
         case 'EXRULE':
6486 6485
         case 'RRULE':
6487 6486
           $values = explode( ';', $line );
6488
-          $recur = array();
6489
-          foreach( $values as $value2 ) {
6487
+            $recur = array();
6488
+            foreach( $values as $value2 ) {
6490 6489
             if( empty( $value2 ))
6491
-              continue; // ;-char in ending position ???
6490
+                continue; // ;-char in ending position ???
6492 6491
             $value3 = explode( '=', $value2, 2 );
6493 6492
             $rulelabel = strtoupper( $value3[0] );
6494 6493
             switch( $rulelabel ) {
6495
-              case 'BYDAY': {
6494
+                case 'BYDAY': {
6496 6495
                 $value4 = explode( ',', $value3[1] );
6497 6496
                 if( 1 < count( $value4 )) {
6498
-                  foreach( $value4 as $v5ix => $value5 ) {
6497
+                    foreach( $value4 as $v5ix => $value5 ) {
6499 6498
                     $value6 = array();
6500 6499
                     $dayno = $dayname = null;
6501 6500
                     $value5 = trim( (string) $value5 );
6502 6501
                     if(( ctype_alpha( substr( $value5, -1 ))) &&
6503 6502
                        ( ctype_alpha( substr( $value5, -2, 1 )))) {
6504
-                      $dayname = substr( $value5, -2, 2 );
6505
-                      if( 2 < strlen( $value5 ))
6503
+                        $dayname = substr( $value5, -2, 2 );
6504
+                        if( 2 < strlen( $value5 ))
6506 6505
                         $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6507 6506
                     }
6508 6507
                     if( $dayno )
6509
-                      $value6[] = $dayno;
6508
+                        $value6[] = $dayno;
6510 6509
                     if( $dayname )
6511
-                      $value6['DAY'] = $dayname;
6510
+                        $value6['DAY'] = $dayname;
6512 6511
                     $value4[$v5ix] = $value6;
6513
-                  }
6512
+                    }
6514 6513
                 }
6515 6514
                 else {
6516
-                  $value4 = array();
6517
-                  $dayno  = $dayname = null;
6518
-                  $value5 = trim( (string) $value3[1] );
6519
-                  if(( ctype_alpha( substr( $value5, -1 ))) &&
6515
+                    $value4 = array();
6516
+                    $dayno  = $dayname = null;
6517
+                    $value5 = trim( (string) $value3[1] );
6518
+                    if(( ctype_alpha( substr( $value5, -1 ))) &&
6520 6519
                      ( ctype_alpha( substr( $value5, -2, 1 )))) {
6521
-                      $dayname = substr( $value5, -2, 2 );
6520
+                        $dayname = substr( $value5, -2, 2 );
6522 6521
                     if( 2 < strlen( $value5 ))
6523
-                      $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6524
-                  }
6525
-                  if( $dayno )
6522
+                        $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6523
+                    }
6524
+                    if( $dayno )
6526 6525
                     $value4[] = $dayno;
6527
-                  if( $dayname )
6526
+                    if( $dayname )
6528 6527
                     $value4['DAY'] = $dayname;
6529 6528
                 }
6530 6529
                 $recur[$rulelabel] = $value4;
6531 6530
                 break;
6532
-              }
6533
-              default: {
6531
+                }
6532
+                default: {
6534 6533
                 $value4 = explode( ',', $value3[1] );
6535 6534
                 if( 1 < count( $value4 ))
6536
-                  $value3[1] = $value4;
6535
+                    $value3[1] = $value4;
6537 6536
                 $recur[$rulelabel] = $value3[1];
6538 6537
                 break;
6539
-              }
6538
+                }
6540 6539
             } // end - switch $rulelabel
6541
-          } // end - foreach( $values.. .
6542
-          $this->setProperty( $propname, $recur, $propattr );
6543
-          break;
6540
+            } // end - foreach( $values.. .
6541
+            $this->setProperty( $propname, $recur, $propattr );
6542
+            break;
6544 6543
         default:
6545 6544
           $this->setProperty( $propname, $line, $propattr );
6546
-          break;
6547
-      } // end  switch( $propname.. .
6545
+            break;
6546
+        } // end  switch( $propname.. .
6548 6547
     } // end - foreach( $proprows.. .
6549 6548
     unset( $this->unparsed, $proprows );
6550 6549
     if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6551
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
6550
+        for( $six = 0; $six < count( $this->components ); $six++ ) {
6552 6551
         if( !empty( $this->components[$six]->unparsed ))
6553
-          $this->components[$six]->parse();
6554
-      }
6552
+            $this->components[$six]->parse();
6553
+        }
6554
+    }
6555 6555
     }
6556
-  }
6557 6556
 /*********************************************************************************/
6558 6557
 /*********************************************************************************/
6559 6558
 /**
@@ -6563,12 +6562,12 @@  discard block
 block discarded – undo
6563 6562
  * @since 2.2.16 - 2007-11-07
6564 6563
  * @return object
6565 6564
  */
6566
-  function copy() {
6565
+    function copy() {
6567 6566
     $serialized_contents = serialize($this);
6568 6567
     $copy = unserialize($serialized_contents);
6569 6568
     unset( $copy->propix );
6570 6569
     return $copy;
6571
- }
6570
+    }
6572 6571
 /*********************************************************************************/
6573 6572
 /*********************************************************************************/
6574 6573
 /**
@@ -6580,187 +6579,187 @@  discard block
 block discarded – undo
6580 6579
  * @param mixed $arg2 optional, ordno if arg1 = component type
6581 6580
  * @return void
6582 6581
  */
6583
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
6582
+    function deleteComponent( $arg1, $arg2=FALSE  ) {
6584 6583
     if( !isset( $this->components )) return FALSE;
6585 6584
     $argType = $index = null;
6586 6585
     if ( ctype_digit( (string) $arg1 )) {
6587
-      $argType = 'INDEX';
6588
-      $index   = (int) $arg1 - 1;
6586
+        $argType = 'INDEX';
6587
+        $index   = (int) $arg1 - 1;
6589 6588
     }
6590 6589
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6591
-      $argType = strtolower( $arg1 );
6592
-      $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6590
+        $argType = strtolower( $arg1 );
6591
+        $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6593 6592
     }
6594 6593
     $cix2dC = 0;
6595 6594
     foreach ( $this->components as $cix => $component) {
6596
-      if( empty( $component )) continue;
6597
-      unset( $component->propix );
6598
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6595
+        if( empty( $component )) continue;
6596
+        unset( $component->propix );
6597
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6599 6598
         unset( $this->components[$cix] );
6600 6599
         return TRUE;
6601
-      }
6602
-      elseif( $argType == $component->objName ) {
6600
+        }
6601
+        elseif( $argType == $component->objName ) {
6603 6602
         if( $index == $cix2dC ) {
6604
-          unset( $this->components[$cix] );
6605
-          return TRUE;
6603
+            unset( $this->components[$cix] );
6604
+            return TRUE;
6606 6605
         }
6607 6606
         $cix2dC++;
6608
-      }
6609
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6607
+        }
6608
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6610 6609
         unset( $this->components[$cix] );
6611 6610
         return TRUE;
6612
-      }
6611
+        }
6613 6612
     }
6614 6613
     return FALSE;
6615
-  }
6614
+    }
6616 6615
 /**
6617
- * get calendar component subcomponent from component container
6618
- *
6619
- * @author Kjell-Inge Gustafsson <[email protected]>
6620
- * @since 2.5.1 - 2008-10-15
6621
- * @param mixed $arg1 optional, ordno/component type/ component uid
6622
- * @param mixed $arg2 optional, ordno if arg1 = component type
6623
- * @return object
6624
- */
6625
-  function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6616
+     * get calendar component subcomponent from component container
6617
+     *
6618
+     * @author Kjell-Inge Gustafsson <[email protected]>
6619
+     * @since 2.5.1 - 2008-10-15
6620
+     * @param mixed $arg1 optional, ordno/component type/ component uid
6621
+     * @param mixed $arg2 optional, ordno if arg1 = component type
6622
+     * @return object
6623
+     */
6624
+    function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6626 6625
     if( !isset( $this->components )) return FALSE;
6627 6626
     $index = $argType = null;
6628 6627
     if ( !$arg1 ) {
6629
-      $argType = 'INDEX';
6630
-      $index   = $this->compix['INDEX'] =
6628
+        $argType = 'INDEX';
6629
+        $index   = $this->compix['INDEX'] =
6631 6630
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6632 6631
     }
6633 6632
     elseif ( ctype_digit( (string) $arg1 )) {
6634
-      $argType = 'INDEX';
6635
-      $index   = (int) $arg1;
6636
-      unset( $this->compix );
6633
+        $argType = 'INDEX';
6634
+        $index   = (int) $arg1;
6635
+        unset( $this->compix );
6637 6636
     }
6638 6637
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6639
-      unset( $this->compix['INDEX'] );
6640
-      $argType = strtolower( $arg1 );
6641
-      if( !$arg2 )
6638
+        unset( $this->compix['INDEX'] );
6639
+        $argType = strtolower( $arg1 );
6640
+        if( !$arg2 )
6642 6641
         $index = $this->compix[$argType] =
6643 6642
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6644
-      else
6643
+        else
6645 6644
         $index = (int) $arg2;
6646 6645
     }
6647 6646
     $index  -= 1;
6648 6647
     $ckeys = array_keys( $this->components );
6649 6648
     if( !empty( $index) && ( $index > end( $ckeys )))
6650
-      return FALSE;
6649
+        return FALSE;
6651 6650
     $cix2gC = 0;
6652 6651
     foreach( $this->components as $cix => $component ) {
6653
-      if( empty( $component )) continue;
6654
-      unset( $component->propix );
6655
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
6652
+        if( empty( $component )) continue;
6653
+        unset( $component->propix );
6654
+        if(( 'INDEX' == $argType ) && ( $index == $cix ))
6656 6655
         return $component->copy();
6657
-      elseif( $argType == $component->objName ) {
6658
-         if( $index == $cix2gC )
6659
-           return $component->copy();
6660
-         $cix2gC++;
6661
-      }
6662
-      elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6656
+        elseif( $argType == $component->objName ) {
6657
+            if( $index == $cix2gC )
6658
+            return $component->copy();
6659
+            $cix2gC++;
6660
+        }
6661
+        elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6663 6662
         unset( $component->propix );
6664 6663
         return $component->copy();
6665
-      }
6664
+        }
6666 6665
     }
6667 6666
             /* not found.. . */
6668 6667
     unset( $this->compix );
6669 6668
     return false;
6670
-  }
6669
+    }
6671 6670
 /**
6672
- * add calendar component as subcomponent to container for subcomponents
6673
- *
6674
- * @author Kjell-Inge Gustafsson <[email protected]>
6675
- * @since 1.x.x - 2007-04-24
6676
- * @param object $component calendar component
6677
- * @return void
6678
- */
6679
-  function addSubComponent ( $component ) {
6671
+     * add calendar component as subcomponent to container for subcomponents
6672
+     *
6673
+     * @author Kjell-Inge Gustafsson <[email protected]>
6674
+     * @since 1.x.x - 2007-04-24
6675
+     * @param object $component calendar component
6676
+     * @return void
6677
+     */
6678
+    function addSubComponent ( $component ) {
6680 6679
     $this->setComponent( $component );
6681
-  }
6680
+    }
6682 6681
 /**
6683
- * add calendar component as subcomponent to container for subcomponents
6684
- *
6685
- * @author Kjell-Inge Gustafsson <[email protected]>
6686
- * @since 2.4.13 - 2008-09-24
6687
- * @param object $component calendar component
6688
- * @param mixed $arg1 optional, ordno/component type/ component uid
6689
- * @param mixed $arg2 optional, ordno if arg1 = component type
6690
- * @return bool
6691
- */
6692
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6682
+     * add calendar component as subcomponent to container for subcomponents
6683
+     *
6684
+     * @author Kjell-Inge Gustafsson <[email protected]>
6685
+     * @since 2.4.13 - 2008-09-24
6686
+     * @param object $component calendar component
6687
+     * @param mixed $arg1 optional, ordno/component type/ component uid
6688
+     * @param mixed $arg2 optional, ordno if arg1 = component type
6689
+     * @return bool
6690
+     */
6691
+    function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6693 6692
     if( !isset( $this->components )) return FALSE;
6694 6693
     if( '' >= $component->getConfig( 'language'))
6695
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
6694
+        $component->setConfig( 'language',  $this->getConfig( 'language' ));
6696 6695
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6697 6696
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6698 6697
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6699 6698
     $component->setConfig( 'format',      $this->getConfig( 'format' ));
6700 6699
     if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6701
-      unset( $component->propix );
6700
+        unset( $component->propix );
6702 6701
             /* make sure dtstamp and uid is set */
6703
-      $dummy = $component->getProperty( 'dtstamp' );
6704
-      $dummy = $component->getProperty( 'uid' );
6702
+        $dummy = $component->getProperty( 'dtstamp' );
6703
+        $dummy = $component->getProperty( 'uid' );
6705 6704
     }
6706 6705
     if( !$arg1 ) {
6707
-      $this->components[] = $component->copy();
6708
-      return TRUE;
6706
+        $this->components[] = $component->copy();
6707
+        return TRUE;
6709 6708
     }
6710 6709
     $argType = $index = null;
6711 6710
     if ( ctype_digit( (string) $arg1 )) {
6712
-      $argType = 'INDEX';
6713
-      $index   = (int) $arg1 - 1;
6711
+        $argType = 'INDEX';
6712
+        $index   = (int) $arg1 - 1;
6714 6713
     }
6715 6714
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6716
-      $argType = strtolower( $arg1 );
6717
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6715
+        $argType = strtolower( $arg1 );
6716
+        $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6718 6717
     }
6719 6718
     $cix2sC = 0;
6720 6719
     foreach ( $this->components as $cix => $component2 ) {
6721
-      if( empty( $component2 )) continue;
6722
-      unset( $component2->propix );
6723
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6720
+        if( empty( $component2 )) continue;
6721
+        unset( $component2->propix );
6722
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6724 6723
         $this->components[$cix] = $component->copy();
6725 6724
         return TRUE;
6726
-      }
6727
-      elseif( $argType == $component2->objName ) {
6725
+        }
6726
+        elseif( $argType == $component2->objName ) {
6728 6727
         if( $index == $cix2sC ) {
6729
-          $this->components[$cix] = $component->copy();
6730
-          return TRUE;
6728
+            $this->components[$cix] = $component->copy();
6729
+            return TRUE;
6731 6730
         }
6732 6731
         $cix2sC++;
6733
-      }
6734
-      elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6732
+        }
6733
+        elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6735 6734
         $this->components[$cix] = $component->copy();
6736 6735
         return TRUE;
6737
-      }
6736
+        }
6738 6737
     }
6739 6738
             /* not found.. . insert anyway.. .*/
6740 6739
     $this->components[] = $component->copy();
6741 6740
     return TRUE;
6742
-  }
6741
+    }
6743 6742
 /**
6744
- * creates formatted output for subcomponents
6745
- *
6746
- * @author Kjell-Inge Gustafsson <[email protected]>
6747
- * @since 2.4.10 - 2008-08-06
6748
- * @return string
6749
- */
6750
-  function createSubComponent() {
6743
+     * creates formatted output for subcomponents
6744
+     *
6745
+     * @author Kjell-Inge Gustafsson <[email protected]>
6746
+     * @since 2.4.10 - 2008-08-06
6747
+     * @return string
6748
+     */
6749
+    function createSubComponent() {
6751 6750
     $output = null;
6752 6751
     foreach( $this->components as $component ) {
6753
-      if( empty( $component )) continue;
6754
-      if( '' >= $component->getConfig( 'language'))
6752
+        if( empty( $component )) continue;
6753
+        if( '' >= $component->getConfig( 'language'))
6755 6754
         $component->setConfig( 'language',  $this->getConfig( 'language' ));
6756
-      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6757
-      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6758
-      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6759
-      $component->setConfig( 'format',      $this->getConfig( 'format' ));
6760
-      $output .= $component->createComponent( $this->xcaldecl );
6755
+        $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6756
+        $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6757
+        $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6758
+        $component->setConfig( 'format',      $this->getConfig( 'format' ));
6759
+        $output .= $component->createComponent( $this->xcaldecl );
6761 6760
     }
6762 6761
     return $output;
6763
-  }
6762
+    }
6764 6763
 /********************************************************************************/
6765 6764
 /**
6766 6765
  * break lines at pos 75
@@ -6784,83 +6783,83 @@  discard block
 block discarded – undo
6784 6783
  * @param string $value
6785 6784
  * @return string
6786 6785
  */
6787
-  function _size75( $string ) {
6786
+    function _size75( $string ) {
6788 6787
     $strlen = strlen( $string );
6789 6788
     $tmp    = $string;
6790 6789
     $string = null;
6791 6790
     while( $strlen > 75 ) {
6792
-       $breakAtChar = 75;
6793
-       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6794
-         $breakAtChar = $breakAtChar - 1;
6795
-       $string .= substr( $tmp, 0, $breakAtChar );
6796
-       $string .= $this->nl;
6797
-       $tmp     = ' '.substr( $tmp, $breakAtChar );
6798
-       $strlen  = strlen( $tmp );
6791
+        $breakAtChar = 75;
6792
+        if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6793
+            $breakAtChar = $breakAtChar - 1;
6794
+        $string .= substr( $tmp, 0, $breakAtChar );
6795
+        $string .= $this->nl;
6796
+        $tmp     = ' '.substr( $tmp, $breakAtChar );
6797
+        $strlen  = strlen( $tmp );
6799 6798
     } // while
6800 6799
     $string .= rtrim( $tmp ); // the rest
6801 6800
     if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6802
-      $string .= $this->nl;
6801
+        $string .= $this->nl;
6803 6802
     return $string;
6804
-  }
6803
+    }
6805 6804
 /**
6806
- * special characters management output
6807
- *
6808
- * @author Kjell-Inge Gustafsson <[email protected]>
6809
- * @since 2.3.3 - 2007-12-20
6810
- * @param string $string
6811
- * @return string
6812
- */
6813
-  function _strrep( $string ) {
6805
+     * special characters management output
6806
+     *
6807
+     * @author Kjell-Inge Gustafsson <[email protected]>
6808
+     * @since 2.3.3 - 2007-12-20
6809
+     * @param string $string
6810
+     * @return string
6811
+     */
6812
+    function _strrep( $string ) {
6814 6813
     switch( $this->format ) {
6815
-      case 'xcal':
6814
+        case 'xcal':
6816 6815
         $string = str_replace( '\n',  $this->nl, $string);
6817 6816
         $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string ))));
6818 6817
         break;
6819
-      default:
6818
+        default:
6820 6819
         $pos = 0;
6821 6820
         while( $pos <= strlen( $string )) {
6822
-          $pos = strpos( $string, "\\", $pos );
6823
-          if( FALSE === $pos )
6821
+            $pos = strpos( $string, "\\", $pos );
6822
+            if( FALSE === $pos )
6824 6823
             break;
6825
-          if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6824
+            if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6826 6825
             $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6827 6826
             $pos += 1;
6828
-          }
6829
-          $pos += 1;
6827
+            }
6828
+            $pos += 1;
6830 6829
         }
6831 6830
         if( FALSE !== strpos( $string, '"' ))
6832
-          $string = str_replace('"',   "'",       $string);
6831
+            $string = str_replace('"',   "'",       $string);
6833 6832
         if( FALSE !== strpos( $string, ',' ))
6834
-          $string = str_replace(',',   '\,',      $string);
6833
+            $string = str_replace(',',   '\,',      $string);
6835 6834
         if( FALSE !== strpos( $string, ';' ))
6836
-          $string = str_replace(';',   '\;',      $string);
6835
+            $string = str_replace(';',   '\;',      $string);
6837 6836
         if( FALSE !== strpos( $string, "\r\n" ))
6838
-          $string = str_replace( "\r\n", '\n',    $string);
6837
+            $string = str_replace( "\r\n", '\n',    $string);
6839 6838
         elseif( FALSE !== strpos( $string, "\r" ))
6840
-          $string = str_replace( "\r", '\n',      $string);
6839
+            $string = str_replace( "\r", '\n',      $string);
6841 6840
         if( FALSE !== strpos( $string, '\N' ))
6842
-          $string = str_replace( '\N', '\n',      $string);
6841
+            $string = str_replace( '\N', '\n',      $string);
6843 6842
 //        if( FALSE !== strpos( $string, $this->nl ))
6844
-          $string = str_replace( $this->nl, '\n', $string);
6843
+            $string = str_replace( $this->nl, '\n', $string);
6845 6844
         break;
6846 6845
     }
6847 6846
     return $string;
6848
-  }
6847
+    }
6849 6848
 /**
6850
- * special characters management input (from iCal file)
6851
- *
6852
- * @author Kjell-Inge Gustafsson <[email protected]>
6853
- * @since 2.3.3 - 2007-11-23
6854
- * @param string $string
6855
- * @return string
6856
- */
6857
-  function _strunrep( $string ) {
6849
+     * special characters management input (from iCal file)
6850
+     *
6851
+     * @author Kjell-Inge Gustafsson <[email protected]>
6852
+     * @since 2.3.3 - 2007-11-23
6853
+     * @param string $string
6854
+     * @return string
6855
+     */
6856
+    function _strunrep( $string ) {
6858 6857
     $string = str_replace( '\\\\', '\\',     $string);
6859 6858
     $string = str_replace( '\,',   ',',      $string);
6860 6859
     $string = str_replace( '\;',   ';',      $string);
6861 6860
 //    $string = str_replace( '\n',  $this->nl, $string); // ??
6862 6861
     return $string;
6863
-  }
6862
+    }
6864 6863
 }
6865 6864
 /*********************************************************************************/
6866 6865
 /*********************************************************************************/
@@ -6871,46 +6870,46 @@  discard block
 block discarded – undo
6871 6870
  * @since 2.5.1 - 2008-10-12
6872 6871
  */
6873 6872
 class vevent extends calendarComponent {
6874
-  var $attach;
6875
-  var $attendee;
6876
-  var $categories;
6877
-  var $comment;
6878
-  var $contact;
6879
-  var $class;
6880
-  var $created;
6881
-  var $description;
6882
-  var $dtend;
6883
-  var $dtstart;
6884
-  var $duration;
6885
-  var $exdate;
6886
-  var $exrule;
6887
-  var $geo;
6888
-  var $lastmodified;
6889
-  var $location;
6890
-  var $organizer;
6891
-  var $priority;
6892
-  var $rdate;
6893
-  var $recurrenceid;
6894
-  var $relatedto;
6895
-  var $requeststatus;
6896
-  var $resources;
6897
-  var $rrule;
6898
-  var $sequence;
6899
-  var $status;
6900
-  var $summary;
6901
-  var $transp;
6902
-  var $url;
6903
-  var $xprop;
6873
+    var $attach;
6874
+    var $attendee;
6875
+    var $categories;
6876
+    var $comment;
6877
+    var $contact;
6878
+    var $class;
6879
+    var $created;
6880
+    var $description;
6881
+    var $dtend;
6882
+    var $dtstart;
6883
+    var $duration;
6884
+    var $exdate;
6885
+    var $exrule;
6886
+    var $geo;
6887
+    var $lastmodified;
6888
+    var $location;
6889
+    var $organizer;
6890
+    var $priority;
6891
+    var $rdate;
6892
+    var $recurrenceid;
6893
+    var $relatedto;
6894
+    var $requeststatus;
6895
+    var $resources;
6896
+    var $rrule;
6897
+    var $sequence;
6898
+    var $status;
6899
+    var $summary;
6900
+    var $transp;
6901
+    var $url;
6902
+    var $xprop;
6904 6903
             //  component subcomponents container
6905
-  var $components;
6906
-/**
6907
- * constructor for calendar component VEVENT object
6908
- *
6909
- * @author Kjell-Inge Gustafsson <[email protected]>
6910
- * @since 2.5.1 - 2008-10-31
6911
- * @return void
6912
- */
6913
-  function vevent() {
6904
+    var $components;
6905
+/**
6906
+     * constructor for calendar component VEVENT object
6907
+     *
6908
+     * @author Kjell-Inge Gustafsson <[email protected]>
6909
+     * @since 2.5.1 - 2008-10-31
6910
+     * @return void
6911
+     */
6912
+    function vevent() {
6914 6913
     $this->calendarComponent();
6915 6914
 
6916 6915
     $this->attach          = '';
@@ -6946,16 +6945,16 @@  discard block
 block discarded – undo
6946 6945
 
6947 6946
     $this->components      = array();
6948 6947
 
6949
-  }
6948
+    }
6950 6949
 /**
6951
- * create formatted output for calendar component VEVENT object instance
6952
- *
6953
- * @author Kjell-Inge Gustafsson <[email protected]>
6954
- * @since 2.5.1 - 2008-11-07
6955
- * @param array $xcaldecl
6956
- * @return string
6957
- */
6958
-  function createComponent( &$xcaldecl ) {
6950
+     * create formatted output for calendar component VEVENT object instance
6951
+     *
6952
+     * @author Kjell-Inge Gustafsson <[email protected]>
6953
+     * @since 2.5.1 - 2008-11-07
6954
+     * @param array $xcaldecl
6955
+     * @return string
6956
+     */
6957
+    function createComponent( &$xcaldecl ) {
6959 6958
     $objectname    = $this->_createFormat();
6960 6959
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
6961 6960
     $component    .= $this->createUid();
@@ -6993,11 +6992,11 @@  discard block
 block discarded – undo
6993 6992
     $component    .= $this->createSubComponent();
6994 6993
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
6995 6994
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
6996
-      foreach( $this->xcaldecl as $localxcaldecl )
6995
+        foreach( $this->xcaldecl as $localxcaldecl )
6997 6996
         $xcaldecl[] = $localxcaldecl;
6998 6997
     }
6999 6998
     return $component;
7000
-  }
6999
+    }
7001 7000
 }
7002 7001
 /*********************************************************************************/
7003 7002
 /*********************************************************************************/
@@ -7008,47 +7007,47 @@  discard block
 block discarded – undo
7008 7007
  * @since 2.5.1 - 2008-10-12
7009 7008
  */
7010 7009
 class vtodo extends calendarComponent {
7011
-  var $attach;
7012
-  var $attendee;
7013
-  var $categories;
7014
-  var $comment;
7015
-  var $completed;
7016
-  var $contact;
7017
-  var $class;
7018
-  var $created;
7019
-  var $description;
7020
-  var $dtstart;
7021
-  var $due;
7022
-  var $duration;
7023
-  var $exdate;
7024
-  var $exrule;
7025
-  var $geo;
7026
-  var $lastmodified;
7027
-  var $location;
7028
-  var $organizer;
7029
-  var $percentcomplete;
7030
-  var $priority;
7031
-  var $rdate;
7032
-  var $recurrenceid;
7033
-  var $relatedto;
7034
-  var $requeststatus;
7035
-  var $resources;
7036
-  var $rrule;
7037
-  var $sequence;
7038
-  var $status;
7039
-  var $summary;
7040
-  var $url;
7041
-  var $xprop;
7010
+    var $attach;
7011
+    var $attendee;
7012
+    var $categories;
7013
+    var $comment;
7014
+    var $completed;
7015
+    var $contact;
7016
+    var $class;
7017
+    var $created;
7018
+    var $description;
7019
+    var $dtstart;
7020
+    var $due;
7021
+    var $duration;
7022
+    var $exdate;
7023
+    var $exrule;
7024
+    var $geo;
7025
+    var $lastmodified;
7026
+    var $location;
7027
+    var $organizer;
7028
+    var $percentcomplete;
7029
+    var $priority;
7030
+    var $rdate;
7031
+    var $recurrenceid;
7032
+    var $relatedto;
7033
+    var $requeststatus;
7034
+    var $resources;
7035
+    var $rrule;
7036
+    var $sequence;
7037
+    var $status;
7038
+    var $summary;
7039
+    var $url;
7040
+    var $xprop;
7042 7041
             //  component subcomponents container
7043
-  var $components;
7044
-/**
7045
- * constructor for calendar component VTODO object
7046
- *
7047
- * @author Kjell-Inge Gustafsson <[email protected]>
7048
- * @since 2.5.1 - 2008-10-31
7049
- * @return void
7050
- */
7051
-  function vtodo() {
7042
+    var $components;
7043
+/**
7044
+     * constructor for calendar component VTODO object
7045
+     *
7046
+     * @author Kjell-Inge Gustafsson <[email protected]>
7047
+     * @since 2.5.1 - 2008-10-31
7048
+     * @return void
7049
+     */
7050
+    function vtodo() {
7052 7051
     $this->calendarComponent();
7053 7052
 
7054 7053
     $this->attach          = '';
@@ -7084,16 +7083,16 @@  discard block
 block discarded – undo
7084 7083
     $this->xprop           = '';
7085 7084
 
7086 7085
     $this->components      = array();
7087
-  }
7086
+    }
7088 7087
 /**
7089
- * create formatted output for calendar component VTODO object instance
7090
- *
7091
- * @author Kjell-Inge Gustafsson <[email protected]>
7092
- * @since 2.5.1 - 2008-11-07
7093
- * @param array $xcaldecl
7094
- * @return string
7095
- */
7096
-  function createComponent( &$xcaldecl ) {
7088
+     * create formatted output for calendar component VTODO object instance
7089
+     *
7090
+     * @author Kjell-Inge Gustafsson <[email protected]>
7091
+     * @since 2.5.1 - 2008-11-07
7092
+     * @param array $xcaldecl
7093
+     * @return string
7094
+     */
7095
+    function createComponent( &$xcaldecl ) {
7097 7096
     $objectname    = $this->_createFormat();
7098 7097
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7099 7098
     $component    .= $this->createUid();
@@ -7132,11 +7131,11 @@  discard block
 block discarded – undo
7132 7131
     $component    .= $this->createSubComponent();
7133 7132
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7134 7133
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7135
-      foreach( $this->xcaldecl as $localxcaldecl )
7134
+        foreach( $this->xcaldecl as $localxcaldecl )
7136 7135
         $xcaldecl[] = $localxcaldecl;
7137 7136
     }
7138 7137
     return $component;
7139
-  }
7138
+    }
7140 7139
 }
7141 7140
 /*********************************************************************************/
7142 7141
 /*********************************************************************************/
@@ -7147,37 +7146,37 @@  discard block
 block discarded – undo
7147 7146
  * @since 2.5.1 - 2008-10-12
7148 7147
  */
7149 7148
 class vjournal extends calendarComponent {
7150
-  var $attach;
7151
-  var $attendee;
7152
-  var $categories;
7153
-  var $comment;
7154
-  var $contact;
7155
-  var $class;
7156
-  var $created;
7157
-  var $description;
7158
-  var $dtstart;
7159
-  var $exdate;
7160
-  var $exrule;
7161
-  var $lastmodified;
7162
-  var $organizer;
7163
-  var $rdate;
7164
-  var $recurrenceid;
7165
-  var $relatedto;
7166
-  var $requeststatus;
7167
-  var $rrule;
7168
-  var $sequence;
7169
-  var $status;
7170
-  var $summary;
7171
-  var $url;
7172
-  var $xprop;
7173
-/**
7174
- * constructor for calendar component VJOURNAL object
7175
- *
7176
- * @author Kjell-Inge Gustafsson <[email protected]>
7177
- * @since 2.5.1 - 2008-10-31
7178
- * @return void
7179
- */
7180
-  function vjournal() {
7149
+    var $attach;
7150
+    var $attendee;
7151
+    var $categories;
7152
+    var $comment;
7153
+    var $contact;
7154
+    var $class;
7155
+    var $created;
7156
+    var $description;
7157
+    var $dtstart;
7158
+    var $exdate;
7159
+    var $exrule;
7160
+    var $lastmodified;
7161
+    var $organizer;
7162
+    var $rdate;
7163
+    var $recurrenceid;
7164
+    var $relatedto;
7165
+    var $requeststatus;
7166
+    var $rrule;
7167
+    var $sequence;
7168
+    var $status;
7169
+    var $summary;
7170
+    var $url;
7171
+    var $xprop;
7172
+/**
7173
+     * constructor for calendar component VJOURNAL object
7174
+     *
7175
+     * @author Kjell-Inge Gustafsson <[email protected]>
7176
+     * @since 2.5.1 - 2008-10-31
7177
+     * @return void
7178
+     */
7179
+    function vjournal() {
7181 7180
     $this->calendarComponent();
7182 7181
 
7183 7182
     $this->attach          = '';
@@ -7203,16 +7202,16 @@  discard block
 block discarded – undo
7203 7202
     $this->summary         = '';
7204 7203
     $this->url             = '';
7205 7204
     $this->xprop           = '';
7206
-  }
7205
+    }
7207 7206
 /**
7208
- * create formatted output for calendar component VJOURNAL object instance
7209
- *
7210
- * @author Kjell-Inge Gustafsson <[email protected]>
7211
- * @since 2.5.1 - 2008-10-12
7212
- * @param array $xcaldecl
7213
- * @return string
7214
- */
7215
-  function createComponent( &$xcaldecl ) {
7207
+     * create formatted output for calendar component VJOURNAL object instance
7208
+     *
7209
+     * @author Kjell-Inge Gustafsson <[email protected]>
7210
+     * @since 2.5.1 - 2008-10-12
7211
+     * @param array $xcaldecl
7212
+     * @return string
7213
+     */
7214
+    function createComponent( &$xcaldecl ) {
7216 7215
     $objectname = $this->_createFormat();
7217 7216
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7218 7217
     $component .= $this->createUid();
@@ -7242,11 +7241,11 @@  discard block
 block discarded – undo
7242 7241
     $component .= $this->createXprop();
7243 7242
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7244 7243
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7245
-      foreach( $this->xcaldecl as $localxcaldecl )
7244
+        foreach( $this->xcaldecl as $localxcaldecl )
7246 7245
         $xcaldecl[] = $localxcaldecl;
7247 7246
     }
7248 7247
     return $component;
7249
-  }
7248
+    }
7250 7249
 }
7251 7250
 /*********************************************************************************/
7252 7251
 /*********************************************************************************/
@@ -7257,27 +7256,27 @@  discard block
 block discarded – undo
7257 7256
  * @since 2.5.1 - 2008-10-12
7258 7257
  */
7259 7258
 class vfreebusy extends calendarComponent {
7260
-  var $attendee;
7261
-  var $comment;
7262
-  var $contact;
7263
-  var $dtend;
7264
-  var $dtstart;
7265
-  var $duration;
7266
-  var $freebusy;
7267
-  var $organizer;
7268
-  var $requeststatus;
7269
-  var $url;
7270
-  var $xprop;
7259
+    var $attendee;
7260
+    var $comment;
7261
+    var $contact;
7262
+    var $dtend;
7263
+    var $dtstart;
7264
+    var $duration;
7265
+    var $freebusy;
7266
+    var $organizer;
7267
+    var $requeststatus;
7268
+    var $url;
7269
+    var $xprop;
7271 7270
             //  component subcomponents container
7272
-  var $components;
7273
-/**
7274
- * constructor for calendar component VFREEBUSY object
7275
- *
7276
- * @author Kjell-Inge Gustafsson <[email protected]>
7277
- * @since 2.5.1 - 2008-10-31
7278
- * @return void
7279
- */
7280
-  function vfreebusy() {
7271
+    var $components;
7272
+/**
7273
+     * constructor for calendar component VFREEBUSY object
7274
+     *
7275
+     * @author Kjell-Inge Gustafsson <[email protected]>
7276
+     * @since 2.5.1 - 2008-10-31
7277
+     * @return void
7278
+     */
7279
+    function vfreebusy() {
7281 7280
     $this->calendarComponent();
7282 7281
 
7283 7282
     $this->attendee        = '';
@@ -7291,16 +7290,16 @@  discard block
 block discarded – undo
7291 7290
     $this->requeststatus   = '';
7292 7291
     $this->url             = '';
7293 7292
     $this->xprop           = '';
7294
-  }
7293
+    }
7295 7294
 /**
7296
- * create formatted output for calendar component VFREEBUSY object instance
7297
- *
7298
- * @author Kjell-Inge Gustafsson <[email protected]>
7299
- * @since 2.3.1 - 2007-11-19
7300
- * @param array $xcaldecl
7301
- * @return string
7302
- */
7303
-  function createComponent( &$xcaldecl ) {
7295
+     * create formatted output for calendar component VFREEBUSY object instance
7296
+     *
7297
+     * @author Kjell-Inge Gustafsson <[email protected]>
7298
+     * @since 2.3.1 - 2007-11-19
7299
+     * @param array $xcaldecl
7300
+     * @return string
7301
+     */
7302
+    function createComponent( &$xcaldecl ) {
7304 7303
     $objectname = $this->_createFormat();
7305 7304
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7306 7305
     $component .= $this->createUid();
@@ -7318,11 +7317,11 @@  discard block
 block discarded – undo
7318 7317
     $component .= $this->createXprop();
7319 7318
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7320 7319
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7321
-      foreach( $this->xcaldecl as $localxcaldecl )
7320
+        foreach( $this->xcaldecl as $localxcaldecl )
7322 7321
         $xcaldecl[] = $localxcaldecl;
7323 7322
     }
7324 7323
     return $component;
7325
-  }
7324
+    }
7326 7325
 }
7327 7326
 /*********************************************************************************/
7328 7327
 /*********************************************************************************/
@@ -7333,23 +7332,23 @@  discard block
 block discarded – undo
7333 7332
  * @since 2.5.1 - 2008-10-12
7334 7333
  */
7335 7334
 class valarm extends calendarComponent {
7336
-  var $action;
7337
-  var $attach;
7338
-  var $attendee;
7339
-  var $description;
7340
-  var $duration;
7341
-  var $repeat;
7342
-  var $summary;
7343
-  var $trigger;
7344
-  var $xprop;
7345
-/**
7346
- * constructor for calendar component VALARM object
7347
- *
7348
- * @author Kjell-Inge Gustafsson <[email protected]>
7349
- * @since 2.5.1 - 2008-10-31
7350
- * @return void
7351
- */
7352
-  function valarm() {
7335
+    var $action;
7336
+    var $attach;
7337
+    var $attendee;
7338
+    var $description;
7339
+    var $duration;
7340
+    var $repeat;
7341
+    var $summary;
7342
+    var $trigger;
7343
+    var $xprop;
7344
+/**
7345
+     * constructor for calendar component VALARM object
7346
+     *
7347
+     * @author Kjell-Inge Gustafsson <[email protected]>
7348
+     * @since 2.5.1 - 2008-10-31
7349
+     * @return void
7350
+     */
7351
+    function valarm() {
7353 7352
     $this->calendarComponent();
7354 7353
 
7355 7354
     $this->action          = '';
@@ -7361,16 +7360,16 @@  discard block
 block discarded – undo
7361 7360
     $this->summary         = '';
7362 7361
     $this->trigger         = '';
7363 7362
     $this->xprop           = '';
7364
-  }
7363
+    }
7365 7364
 /**
7366
- * create formatted output for calendar component VALARM object instance
7367
- *
7368
- * @author Kjell-Inge Gustafsson <[email protected]>
7369
- * @since 2.5.1 - 2008-10-22
7370
- * @param array $xcaldecl
7371
- * @return string
7372
- */
7373
-  function createComponent( &$xcaldecl ) {
7365
+     * create formatted output for calendar component VALARM object instance
7366
+     *
7367
+     * @author Kjell-Inge Gustafsson <[email protected]>
7368
+     * @since 2.5.1 - 2008-10-22
7369
+     * @param array $xcaldecl
7370
+     * @return string
7371
+     */
7372
+    function createComponent( &$xcaldecl ) {
7374 7373
     $objectname    = $this->_createFormat();
7375 7374
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7376 7375
     $component    .= $this->createAction();
@@ -7384,7 +7383,7 @@  discard block
 block discarded – undo
7384 7383
     $component    .= $this->createXprop();
7385 7384
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7386 7385
     return $component;
7387
-  }
7386
+    }
7388 7387
 }
7389 7388
 /**********************************************************************************
7390 7389
 /*********************************************************************************/
@@ -7395,34 +7394,34 @@  discard block
 block discarded – undo
7395 7394
  * @since 2.5.1 - 2008-10-12
7396 7395
  */
7397 7396
 class vtimezone extends calendarComponent {
7398
-  var $timezonetype;
7397
+    var $timezonetype;
7399 7398
 
7400
-  var $comment;
7401
-  var $dtstart;
7402
-  var $lastmodified;
7403
-  var $rdate;
7404
-  var $rrule;
7405
-  var $tzid;
7406
-  var $tzname;
7407
-  var $tzoffsetfrom;
7408
-  var $tzoffsetto;
7409
-  var $tzurl;
7410
-  var $xprop;
7399
+    var $comment;
7400
+    var $dtstart;
7401
+    var $lastmodified;
7402
+    var $rdate;
7403
+    var $rrule;
7404
+    var $tzid;
7405
+    var $tzname;
7406
+    var $tzoffsetfrom;
7407
+    var $tzoffsetto;
7408
+    var $tzurl;
7409
+    var $xprop;
7411 7410
             //  component subcomponents container
7412
-  var $components;
7413
-/**
7414
- * constructor for calendar component VTIMEZONE object
7415
- *
7416
- * @author Kjell-Inge Gustafsson <[email protected]>
7417
- * @since 2.5.1 - 2008-10-31
7418
- * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT )
7419
- * @return void
7420
- */
7421
-  function vtimezone( $timezonetype=FALSE ) {
7411
+    var $components;
7412
+/**
7413
+     * constructor for calendar component VTIMEZONE object
7414
+     *
7415
+     * @author Kjell-Inge Gustafsson <[email protected]>
7416
+     * @since 2.5.1 - 2008-10-31
7417
+     * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT )
7418
+     * @return void
7419
+     */
7420
+    function vtimezone( $timezonetype=FALSE ) {
7422 7421
     if( !$timezonetype )
7423
-      $this->timezonetype = 'VTIMEZONE';
7422
+        $this->timezonetype = 'VTIMEZONE';
7424 7423
     else
7425
-      $this->timezonetype = strtoupper( $timezonetype );
7424
+        $this->timezonetype = strtoupper( $timezonetype );
7426 7425
     $this->calendarComponent();
7427 7426
 
7428 7427
     $this->comment         = '';
@@ -7438,16 +7437,16 @@  discard block
 block discarded – undo
7438 7437
     $this->xprop           = '';
7439 7438
 
7440 7439
     $this->components      = array();
7441
-  }
7440
+    }
7442 7441
 /**
7443
- * create formatted output for calendar component VTIMEZONE object instance
7444
- *
7445
- * @author Kjell-Inge Gustafsson <[email protected]>
7446
- * @since 2.5.1 - 2008-10-25
7447
- * @param array $xcaldecl
7448
- * @return string
7449
- */
7450
-  function createComponent( &$xcaldecl ) {
7442
+     * create formatted output for calendar component VTIMEZONE object instance
7443
+     *
7444
+     * @author Kjell-Inge Gustafsson <[email protected]>
7445
+     * @since 2.5.1 - 2008-10-25
7446
+     * @param array $xcaldecl
7447
+     * @return string
7448
+     */
7449
+    function createComponent( &$xcaldecl ) {
7451 7450
     $objectname    = $this->_createFormat();
7452 7451
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7453 7452
     $component    .= $this->createTzid();
@@ -7464,10 +7463,10 @@  discard block
 block discarded – undo
7464 7463
     $component    .= $this->createSubComponent();
7465 7464
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7466 7465
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7467
-      foreach( $this->xcaldecl as $localxcaldecl )
7466
+        foreach( $this->xcaldecl as $localxcaldecl )
7468 7467
         $xcaldecl[] = $localxcaldecl;
7469 7468
     }
7470 7469
     return $component;
7471
-  }
7470
+    }
7472 7471
 }
7473 7472
 ?>
7474 7473
\ No newline at end of file
Please login to merge, or discard this patch.
main/inc/lib/image.lib.php 4 patches
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@  discard block
 block discarded – undo
52 52
         }
53 53
     }
54 54
     
55
+    /**
56
+     * @param string|null $cropParameters
57
+     */
55 58
     public function crop($cropParameters) {
56 59
         $image_size = $this->get_image_size($this->image_wrapper->path);
57 60
         $src_width = $image_size['width'];
@@ -66,6 +69,9 @@  discard block
 block discarded – undo
66 69
         return $image;
67 70
     }
68 71
 
72
+    /**
73
+     * @param string $convert_file_to
74
+     */
69 75
     public function send_image(
70 76
         $file = '',
71 77
         $compress = -1,
@@ -147,6 +153,9 @@  discard block
 block discarded – undo
147 153
     public $image;
148 154
     public $filter = Imagick::FILTER_LANCZOS;
149 155
 
156
+    /**
157
+     * @param string $path
158
+     */
150 159
     public function __construct($path)
151 160
     {
152 161
           parent::__construct($path);
@@ -194,6 +203,10 @@  discard block
 block discarded – undo
194 203
 	}
195 204
 
196 205
 	//@todo implement border logic case for Imagick
206
+
207
+	/**
208
+	 * @param integer $border
209
+	 */
197 210
 	public function resize($thumbw, $thumbh, $border, $specific_size = false)
198 211
     {
199 212
 	    if (!$this->image_validated) return false;
@@ -275,6 +288,9 @@  discard block
 block discarded – undo
275 288
 {
276 289
     public $bg;
277 290
 
291
+    /**
292
+     * @param string $path
293
+     */
278 294
     function __construct($path) {
279 295
         parent::__construct($path);
280 296
     }
@@ -332,6 +348,9 @@  discard block
 block discarded – undo
332 348
     	}
333 349
     }
334 350
 
351
+    /**
352
+     * @param integer $border
353
+     */
335 354
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
336 355
     {
337 356
         if (!$this->image_validated) return false;
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             if ($height >= $max_size_for_picture) {
48 48
                 // scale width
49 49
                 $new_width = round($width * ($max_size_for_picture / $height));
50
-                 $this->image_wrapper->resize($new_width, $max_size_for_picture, 0);
50
+                    $this->image_wrapper->resize($new_width, $max_size_for_picture, 0);
51 51
             }
52 52
         }
53 53
     }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function __construct($path)
151 151
     {
152
-          parent::__construct($path);
152
+            parent::__construct($path);
153 153
     }
154 154
 
155 155
     public function set_image_wrapper()
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
         }
185 185
     }
186 186
 
187
-	public function get_image_size()
187
+    public function get_image_size()
188 188
     {
189
-		$imagesize = array('width'=>0,'height'=>0);
190
-	    if ($this->image_validated) {
189
+        $imagesize = array('width'=>0,'height'=>0);
190
+        if ($this->image_validated) {
191 191
             $imagesize = $this->image->getImageGeometry();
192
-	    }
193
-	    return $imagesize;
194
-	}
192
+        }
193
+        return $imagesize;
194
+    }
195 195
 
196
-	//@todo implement border logic case for Imagick
197
-	public function resize($thumbw, $thumbh, $border, $specific_size = false)
196
+    //@todo implement border logic case for Imagick
197
+    public function resize($thumbw, $thumbh, $border, $specific_size = false)
198 198
     {
199
-	    if (!$this->image_validated) return false;
199
+        if (!$this->image_validated) return false;
200 200
 
201 201
         if ($specific_size) {
202 202
             $width = $thumbw;
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
             $width  = (int)($this->width * $scale);
207 207
             $height = (int)($this->height * $scale);
208 208
         }
209
-		$result = $this->image->resizeImage($width, $height, $this->filter, 1);
210
-		$this->width  = $thumbw;
211
-		$this->height = $thumbh;
212
-	}
209
+        $result = $this->image->resizeImage($width, $height, $this->filter, 1);
210
+        $this->width  = $thumbw;
211
+        $this->height = $thumbh;
212
+    }
213 213
     
214 214
     /**
215 215
      * @author José Loguercio <[email protected]>
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
225 225
         if (!$this->image_validated) return false;
226 226
         $this->image->cropimage($width, $height, $x, $y);
227
-		$this->width  = $width;
228
-		$this->height = $height;
227
+        $this->width  = $width;
228
+        $this->height = $height;
229 229
     }
230 230
 
231 231
     public function send_image($file = '', $compress = -1, $convert_file_to = null)
@@ -235,35 +235,35 @@  discard block
 block discarded – undo
235 235
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
236 236
             $type = $convert_file_to;
237 237
         }
238
-		switch ($type) {
239
-		    case 'jpeg':
240
-			case 'jpg':
241
-				if (!$file) header("Content-type: image/jpeg");
242
-				break;
243
-			case 'png':
244
-				if (!$file) header("Content-type: image/png");
245
-				break;
246
-			case 'gif':
247
-				if (!$file) header("Content-type: image/gif");
248
-				break;
249
-		}
250
-		$result = false;
251
-		try {
252
-		    $result = $this->image->writeImage($file);
253
-		} catch(ImagickException $e) {
238
+        switch ($type) {
239
+            case 'jpeg':
240
+            case 'jpg':
241
+                if (!$file) header("Content-type: image/jpeg");
242
+                break;
243
+            case 'png':
244
+                if (!$file) header("Content-type: image/png");
245
+                break;
246
+            case 'gif':
247
+                if (!$file) header("Content-type: image/gif");
248
+                break;
249
+        }
250
+        $result = false;
251
+        try {
252
+            $result = $this->image->writeImage($file);
253
+        } catch(ImagickException $e) {
254 254
             if ($this->debug) error_log($e->getMessage());
255 255
         }
256 256
 
257
-		if (!$file) {
258
-		    echo $this->image;
259
-		    $this->image->clear();
257
+        if (!$file) {
258
+            echo $this->image;
259
+            $this->image->clear();
260 260
             $this->image->destroy();
261
-		} else {
262
-		    $this->image->clear();
261
+        } else {
262
+            $this->image->clear();
263 263
             $this->image->destroy();
264
-		    return $result;
265
-		}
266
-	}
264
+            return $result;
265
+        }
266
+    }
267 267
 
268 268
 }
269 269
 
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
         $this->fill_image_info();
286 286
 
287 287
         switch ($this->type) {
288
-        	case 0:
289
-        		$handler = false;
290
-        		break;
291
-		    case 1 :
288
+            case 0:
289
+                $handler = false;
290
+                break;
291
+            case 1 :
292 292
                 $handler = @imagecreatefromgif($this->path);
293 293
                 $this->type = 'gif';
294 294
                 break;
295
-		    case 2 :
295
+            case 2 :
296 296
                 $handler = @imagecreatefromjpeg($this->path);
297 297
                 $this->type = 'jpg';
298 298
                 break;
299
-		    case 3 :
300
-		        $handler = @imagecreatefrompng($this->path);
301
-		        $this->type = 'png';
302
-		        break;
299
+            case 3 :
300
+                $handler = @imagecreatefrompng($this->path);
301
+                $this->type = 'png';
302
+                break;
303 303
         }
304 304
         if ($handler) {
305 305
             $this->image_validated = true;
@@ -313,29 +313,29 @@  discard block
 block discarded – undo
313 313
     {
314 314
         $return_array = array('width'=>0,'height'=>0);
315 315
         if ($this->image_validated) {
316
-	        $return_array = array('width'=>$this->width,'height'=>$this->height);
316
+            $return_array = array('width'=>$this->width,'height'=>$this->height);
317 317
         }
318 318
         return $return_array;
319
-	}
319
+    }
320 320
 
321 321
     public function fill_image_info()
322 322
     {
323
-    	if (file_exists($this->path)) {
324
-	        $image_info     = getimagesize($this->path);
325
-			$this->width    = $image_info[0];
326
-			$this->height   = $image_info[1];
327
-			$this->type     = $image_info[2];
328
-    	} else {
329
-    		$this->width    = 0;
330
-    		$this->height   = 0;
331
-    		$this->type     = 0;
332
-    	}
323
+        if (file_exists($this->path)) {
324
+            $image_info     = getimagesize($this->path);
325
+            $this->width    = $image_info[0];
326
+            $this->height   = $image_info[1];
327
+            $this->type     = $image_info[2];
328
+        } else {
329
+            $this->width    = 0;
330
+            $this->height   = 0;
331
+            $this->type     = 0;
332
+        }
333 333
     }
334 334
 
335 335
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
336 336
     {
337 337
         if (!$this->image_validated) return false;
338
-		if ($border == 1) {
338
+        if ($border == 1) {
339 339
             if ($specific_size) {
340 340
                 $width = $thumbw;
341 341
                 $height = $thumbh;
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
                 $width = (int)($this->width * $scale);
345 345
                 $height = (int)($this->height * $scale);
346 346
             }
347
-			$deltaw = (int)(($thumbw - $width) / 2);
348
-			$deltah = (int)(($thumbh - $height) / 2);
349
-			$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350
-            		@imagealphablending($dst_img, false);
351
-		        @imagesavealpha($dst_img, true);
352
-			if (!empty($this->color)) {
353
-				@imagefill($dst_img, 0, 0, $this->color);
354
-			}
355
-			$this->width = $thumbw;
356
-			$this->height = $thumbh;
357
-		} elseif ($border == 0) {
347
+            $deltaw = (int)(($thumbw - $width) / 2);
348
+            $deltah = (int)(($thumbh - $height) / 2);
349
+            $dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350
+                    @imagealphablending($dst_img, false);
351
+                @imagesavealpha($dst_img, true);
352
+            if (!empty($this->color)) {
353
+                @imagefill($dst_img, 0, 0, $this->color);
354
+            }
355
+            $this->width = $thumbw;
356
+            $this->height = $thumbh;
357
+        } elseif ($border == 0) {
358 358
             if ($specific_size) {
359 359
                 $width = $thumbw;
360 360
                 $height = $thumbh;
@@ -363,19 +363,19 @@  discard block
 block discarded – undo
363 363
                 $width  = (int)($this->width * $scale);
364 364
                 $height = (int)($this->height * $scale);
365 365
             }
366
-			$deltaw = 0;
367
-			$deltah = 0;
368
-			$dst_img = @ImageCreateTrueColor($width, $height);
369
-            		@imagealphablending($dst_img, false);
370
-		        @imagesavealpha($dst_img, true);
371
-			$this->width = $width;
372
-			$this->height = $height;
373
-		}
374
-		$src_img = $this->bg;
375
-		@ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img));
376
-		$this->bg = $dst_img;
377
-		@imagedestroy($src_img);
378
-	}
366
+            $deltaw = 0;
367
+            $deltah = 0;
368
+            $dst_img = @ImageCreateTrueColor($width, $height);
369
+                    @imagealphablending($dst_img, false);
370
+                @imagesavealpha($dst_img, true);
371
+            $this->width = $width;
372
+            $this->height = $height;
373
+        }
374
+        $src_img = $this->bg;
375
+        @ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img));
376
+        $this->bg = $dst_img;
377
+        @imagedestroy($src_img);
378
+    }
379 379
     
380 380
     /**
381 381
      * @author José Loguercio <[email protected]>
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
390 390
         if (!$this->image_validated) return false;
391 391
         $this->width = $width;
392
-		$this->height = $height;
392
+        $this->height = $height;
393 393
         $src = null;
394 394
         $dest = @imagecreatetruecolor($width, $height);
395 395
         $type = $this->type;
@@ -400,56 +400,56 @@  discard block
 block discarded – undo
400 400
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
401 401
                 @imagejpeg($dest, $this->path);
402 402
                 break;
403
-		    case 'png' :
403
+            case 'png' :
404 404
                 $src = @imagecreatefrompng($this->path);
405 405
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
406 406
                 @imagepng($dest, $this->path);
407 407
                 break;
408
-		    case 'gif' :
409
-		        $src = @imagecreatefromgif($this->path);
408
+            case 'gif' :
409
+                $src = @imagecreatefromgif($this->path);
410 410
                 @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height);
411 411
                 @imagegif($dest, $this->path);
412
-		        break;
412
+                break;
413 413
             default: return 0;
414 414
         }
415 415
         @imagedestroy($dest);
416 416
         @imagedestroy($src);
417 417
     }
418 418
 
419
-	public function send_image($file = '', $compress = -1, $convert_file_to = null)
419
+    public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 420
     {
421
-	    if (!$this->image_validated) return false;
421
+        if (!$this->image_validated) return false;
422 422
         $compress = (int)$compress;
423 423
         $type = $this->type;
424 424
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
425 425
             $type = $convert_file_to;
426 426
         }
427
-		switch ($type) {
428
-		    case 'jpeg':
429
-			case 'jpg':
430
-				if (!$file) header("Content-type: image/jpeg");
431
-				if ($compress == -1) $compress = 100;
432
-				return imagejpeg($this->bg, $file, $compress);
433
-				break;
434
-			case 'png':
435
-				if (!$file) header("Content-type: image/png");
436
-				if ($compress != -1) {
437
-					@imagetruecolortopalette($this->bg, true, $compress);
438
-				}
439
-				return imagepng($this->bg, $file, $compress);
440
-				break;
441
-			case 'gif':
442
-				if (!$file) header("Content-type: image/gif");
443
-				if ($compress != -1) {
444
-					@imagetruecolortopalette($this->bg, true, $compress);
445
-				}
446
-				return imagegif($this->bg, $file, $compress);
447
-				break;
448
-			default: return 0;
449
-		}
450
-		// TODO: Occupied memory is not released, because the following fragment of code is actually dead.
451
-		@imagedestroy($this->bg);
452
-	}
427
+        switch ($type) {
428
+            case 'jpeg':
429
+            case 'jpg':
430
+                if (!$file) header("Content-type: image/jpeg");
431
+                if ($compress == -1) $compress = 100;
432
+                return imagejpeg($this->bg, $file, $compress);
433
+                break;
434
+            case 'png':
435
+                if (!$file) header("Content-type: image/png");
436
+                if ($compress != -1) {
437
+                    @imagetruecolortopalette($this->bg, true, $compress);
438
+                }
439
+                return imagepng($this->bg, $file, $compress);
440
+                break;
441
+            case 'gif':
442
+                if (!$file) header("Content-type: image/gif");
443
+                if ($compress != -1) {
444
+                    @imagetruecolortopalette($this->bg, true, $compress);
445
+                }
446
+                return imagegif($this->bg, $file, $compress);
447
+                break;
448
+            default: return 0;
449
+        }
450
+        // TODO: Occupied memory is not released, because the following fragment of code is actually dead.
451
+        @imagedestroy($this->bg);
452
+    }
453 453
 
454 454
     /**
455 455
      * Convert image to black & white
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             return false;
116 116
         }
117 117
         $this->path = preg_match(VALID_WEB_PATH, $path) ? (api_is_internal_path($path) ? api_get_path(TO_SYS, $path) : $path) : $path;
118
-        $this->set_image_wrapper();  //Creates image obj
118
+        $this->set_image_wrapper(); //Creates image obj
119 119
     }
120 120
 
121 121
     abstract function set_image_wrapper();
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         if ($this->debug) error_log('Image::set_image_wrapper loaded');
158 158
         try {
159 159
             if (file_exists($this->path)) {
160
-                $this->image     = new Imagick($this->path);
160
+                $this->image = new Imagick($this->path);
161 161
 
162 162
                 if ($this->image) {
163 163
                     $this->fill_image_info(); //Fills height, width and type
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             } else {
166 166
                 if ($this->debug) error_log('Image::image does not exist');
167 167
             }
168
-        } catch(ImagickException $e) {
168
+        } catch (ImagickException $e) {
169 169
             if ($this->debug) error_log($e->getMessage());
170 170
         }
171 171
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 	public function get_image_size()
188 188
     {
189
-		$imagesize = array('width'=>0,'height'=>0);
189
+		$imagesize = array('width'=>0, 'height'=>0);
190 190
 	    if ($this->image_validated) {
191 191
             $imagesize = $this->image->getImageGeometry();
192 192
 	    }
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
             $height = $thumbh;
204 204
         } else {
205 205
             $scale  = ($this->width > 0 && $this->height > 0) ? min($thumbw / $this->width, $thumbh / $this->height) : 0;
206
-            $width  = (int)($this->width * $scale);
207
-            $height = (int)($this->height * $scale);
206
+            $width  = (int) ($this->width * $scale);
207
+            $height = (int) ($this->height * $scale);
208 208
         }
209 209
 		$result = $this->image->resizeImage($width, $height, $this->filter, 1);
210 210
 		$this->width  = $thumbw;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$result = false;
251 251
 		try {
252 252
 		    $result = $this->image->writeImage($file);
253
-		} catch(ImagickException $e) {
253
+		} catch (ImagickException $e) {
254 254
             if ($this->debug) error_log($e->getMessage());
255 255
         }
256 256
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 
312 312
     public function get_image_size()
313 313
     {
314
-        $return_array = array('width'=>0,'height'=>0);
314
+        $return_array = array('width'=>0, 'height'=>0);
315 315
         if ($this->image_validated) {
316
-	        $return_array = array('width'=>$this->width,'height'=>$this->height);
316
+	        $return_array = array('width'=>$this->width, 'height'=>$this->height);
317 317
         }
318 318
         return $return_array;
319 319
 	}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     public function fill_image_info()
322 322
     {
323 323
     	if (file_exists($this->path)) {
324
-	        $image_info     = getimagesize($this->path);
324
+	        $image_info = getimagesize($this->path);
325 325
 			$this->width    = $image_info[0];
326 326
 			$this->height   = $image_info[1];
327 327
 			$this->type     = $image_info[2];
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
                 $height = $thumbh;
342 342
             } else {
343 343
                 $scale = min($thumbw / $this->width, $thumbh / $this->height);
344
-                $width = (int)($this->width * $scale);
345
-                $height = (int)($this->height * $scale);
344
+                $width = (int) ($this->width * $scale);
345
+                $height = (int) ($this->height * $scale);
346 346
             }
347
-			$deltaw = (int)(($thumbw - $width) / 2);
348
-			$deltah = (int)(($thumbh - $height) / 2);
347
+			$deltaw = (int) (($thumbw - $width) / 2);
348
+			$deltah = (int) (($thumbh - $height) / 2);
349 349
 			$dst_img = @ImageCreateTrueColor($thumbw, $thumbh);
350 350
             		@imagealphablending($dst_img, false);
351 351
 		        @imagesavealpha($dst_img, true);
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
                 $height = $thumbh;
361 361
             } else {
362 362
                 $scale = ($this->width > 0 && $this->height > 0) ? min($thumbw / $this->width, $thumbh / $this->height) : 0;
363
-                $width  = (int)($this->width * $scale);
364
-                $height = (int)($this->height * $scale);
363
+                $width  = (int) ($this->width * $scale);
364
+                $height = (int) ($this->height * $scale);
365 365
             }
366 366
 			$deltaw = 0;
367 367
 			$deltah = 0;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 420
     {
421 421
 	    if (!$this->image_validated) return false;
422
-        $compress = (int)$compress;
422
+        $compress = (int) $compress;
423 423
         $type = $this->type;
424 424
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
425 425
             $type = $convert_file_to;
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
          * so that we can use black (0,0,0) as transparent, which is what
464 464
          * the image is filled with when created.
465 465
          */
466
-        $transparent = imagecolorallocate($dest_img, 0,0,0);
466
+        $transparent = imagecolorallocate($dest_img, 0, 0, 0);
467 467
         imagealphablending($dest_img, false);
468 468
         imagesavealpha($dest_img, true);
469 469
         imagecolortransparent($dest_img, $transparent);
470
-        imagecopy($dest_img, $this->bg, 0,0, 0, 0,imagesx($this->bg), imagesx($this->bg));
470
+        imagecopy($dest_img, $this->bg, 0, 0, 0, 0, imagesx($this->bg), imagesx($this->bg));
471 471
         imagefilter($dest_img, IMG_FILTER_GRAYSCALE);
472 472
         $this->bg = $dest_img;
473 473
 
Please login to merge, or discard this patch.
Braces   +57 added lines, -19 removed lines patch added patch discarded remove patch
@@ -154,7 +154,9 @@  discard block
 block discarded – undo
154 154
 
155 155
     public function set_image_wrapper()
156 156
     {
157
-        if ($this->debug) error_log('Image::set_image_wrapper loaded');
157
+        if ($this->debug) {
158
+            error_log('Image::set_image_wrapper loaded');
159
+        }
158 160
         try {
159 161
             if (file_exists($this->path)) {
160 162
                 $this->image     = new Imagick($this->path);
@@ -163,10 +165,14 @@  discard block
 block discarded – undo
163 165
                     $this->fill_image_info(); //Fills height, width and type
164 166
                 }
165 167
             } else {
166
-                if ($this->debug) error_log('Image::image does not exist');
168
+                if ($this->debug) {
169
+                    error_log('Image::image does not exist');
170
+                }
167 171
             }
168 172
         } catch(ImagickException $e) {
169
-            if ($this->debug) error_log($e->getMessage());
173
+            if ($this->debug) {
174
+                error_log($e->getMessage());
175
+            }
170 176
         }
171 177
     }
172 178
 
@@ -180,7 +186,9 @@  discard block
 block discarded – undo
180 186
 
181 187
         if (in_array($this->type, $this->allowed_extensions)) {
182 188
             $this->image_validated = true;
183
-            if ($this->debug) error_log('image_validated true');
189
+            if ($this->debug) {
190
+                error_log('image_validated true');
191
+            }
184 192
         }
185 193
     }
186 194
 
@@ -196,7 +204,9 @@  discard block
 block discarded – undo
196 204
 	//@todo implement border logic case for Imagick
197 205
 	public function resize($thumbw, $thumbh, $border, $specific_size = false)
198 206
     {
199
-	    if (!$this->image_validated) return false;
207
+	    if (!$this->image_validated) {
208
+	        return false;
209
+	    }
200 210
 
201 211
         if ($specific_size) {
202 212
             $width = $thumbw;
@@ -222,7 +232,9 @@  discard block
 block discarded – undo
222 232
      */
223 233
     
224 234
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
225
-        if (!$this->image_validated) return false;
235
+        if (!$this->image_validated) {
236
+            return false;
237
+        }
226 238
         $this->image->cropimage($width, $height, $x, $y);
227 239
 		$this->width  = $width;
228 240
 		$this->height = $height;
@@ -230,7 +242,9 @@  discard block
 block discarded – undo
230 242
 
231 243
     public function send_image($file = '', $compress = -1, $convert_file_to = null)
232 244
     {
233
-        if (!$this->image_validated) return false;
245
+        if (!$this->image_validated) {
246
+            return false;
247
+        }
234 248
         $type = $this->type;
235 249
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
236 250
             $type = $convert_file_to;
@@ -238,20 +252,28 @@  discard block
 block discarded – undo
238 252
 		switch ($type) {
239 253
 		    case 'jpeg':
240 254
 			case 'jpg':
241
-				if (!$file) header("Content-type: image/jpeg");
255
+				if (!$file) {
256
+				    header("Content-type: image/jpeg");
257
+				}
242 258
 				break;
243 259
 			case 'png':
244
-				if (!$file) header("Content-type: image/png");
260
+				if (!$file) {
261
+				    header("Content-type: image/png");
262
+				}
245 263
 				break;
246 264
 			case 'gif':
247
-				if (!$file) header("Content-type: image/gif");
265
+				if (!$file) {
266
+				    header("Content-type: image/gif");
267
+				}
248 268
 				break;
249 269
 		}
250 270
 		$result = false;
251 271
 		try {
252 272
 		    $result = $this->image->writeImage($file);
253 273
 		} catch(ImagickException $e) {
254
-            if ($this->debug) error_log($e->getMessage());
274
+            if ($this->debug) {
275
+                error_log($e->getMessage());
276
+            }
255 277
         }
256 278
 
257 279
 		if (!$file) {
@@ -334,7 +356,9 @@  discard block
 block discarded – undo
334 356
 
335 357
     public function resize($thumbw, $thumbh, $border, $specific_size = false)
336 358
     {
337
-        if (!$this->image_validated) return false;
359
+        if (!$this->image_validated) {
360
+            return false;
361
+        }
338 362
 		if ($border == 1) {
339 363
             if ($specific_size) {
340 364
                 $width = $thumbw;
@@ -387,7 +411,9 @@  discard block
 block discarded – undo
387 411
      * @param int $src_height the source height of the original image
388 412
      */
389 413
     public function crop($x, $y, $width, $height, $src_width, $src_height) {
390
-        if (!$this->image_validated) return false;
414
+        if (!$this->image_validated) {
415
+            return false;
416
+        }
391 417
         $this->width = $width;
392 418
 		$this->height = $height;
393 419
         $src = null;
@@ -418,7 +444,9 @@  discard block
 block discarded – undo
418 444
 
419 445
 	public function send_image($file = '', $compress = -1, $convert_file_to = null)
420 446
     {
421
-	    if (!$this->image_validated) return false;
447
+	    if (!$this->image_validated) {
448
+	        return false;
449
+	    }
422 450
         $compress = (int)$compress;
423 451
         $type = $this->type;
424 452
         if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
@@ -427,19 +455,27 @@  discard block
 block discarded – undo
427 455
 		switch ($type) {
428 456
 		    case 'jpeg':
429 457
 			case 'jpg':
430
-				if (!$file) header("Content-type: image/jpeg");
431
-				if ($compress == -1) $compress = 100;
458
+				if (!$file) {
459
+				    header("Content-type: image/jpeg");
460
+				}
461
+				if ($compress == -1) {
462
+				    $compress = 100;
463
+				}
432 464
 				return imagejpeg($this->bg, $file, $compress);
433 465
 				break;
434 466
 			case 'png':
435
-				if (!$file) header("Content-type: image/png");
467
+				if (!$file) {
468
+				    header("Content-type: image/png");
469
+				}
436 470
 				if ($compress != -1) {
437 471
 					@imagetruecolortopalette($this->bg, true, $compress);
438 472
 				}
439 473
 				return imagepng($this->bg, $file, $compress);
440 474
 				break;
441 475
 			case 'gif':
442
-				if (!$file) header("Content-type: image/gif");
476
+				if (!$file) {
477
+				    header("Content-type: image/gif");
478
+				}
443 479
 				if ($compress != -1) {
444 480
 					@imagetruecolortopalette($this->bg, true, $compress);
445 481
 				}
@@ -456,7 +492,9 @@  discard block
 block discarded – undo
456 492
      */
457 493
     function convert2bw()
458 494
     {
459
-        if (!$this->image_validated) return false;
495
+        if (!$this->image_validated) {
496
+            return false;
497
+        }
460 498
 
461 499
         $dest_img = imagecreatetruecolor(imagesx($this->bg), imagesy($this->bg));
462 500
         /* copy ignore the transparent color
Please login to merge, or discard this patch.