Code Duplication    Length = 18-20 lines in 2 locations

main/inc/lib/icalcreator/iCalcreator.class.php 2 locations

@@ 996-1013 (lines=18) @@
993
                        $rend   = $component2->_date2timestamp( $rend );
994
                        $rstart = $recurkey;
995
                        /* add repeating components within valid dates to output array, only start date */
996
                        if( $flat )
997
                            $result[] = $component2->copy(); // copy to output
998
                        elseif( $split ) {
999
                            if( $rend > $endDate )
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
1005
                                    $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1006
                                $rstart += ( 24*60*60 ); // step one day
1007
                            }
1008
                        }
1009
                        elseif(( $rstart >= $startDate ) &&     // date within period
1010
                            !isset( $exdatelist[$rstart] )) { // check exclude date
1011
                            $wd = getdate( $rstart );
1012
                            $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1013
                        }
1014
                    }
1015
                }
1016
                /* deselect components with startdate/enddate not within period */
@@ 1022-1041 (lines=20) @@
1019
            /* deselect components with startdate not within period */
1020
            elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1021
            /* add selected components within valid dates to output array */
1022
            if( $flat )
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 )
1029
                        $startWdate = $startDate; // use period start date
1030
                    while( $startWdate <= $endWdate ) { // iterate
1031
                        $wd = getdate( $startWdate );
1032
                        $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1033
                        $startWdate += ( 24*60*60 ); // step one day
1034
                    }
1035
                }
1036
            } // use component date
1037
            elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1038
                ( $startWdate >= $startDate )) {          // within period
1039
                $wd = getdate( $startWdate );
1040
                $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041
            }
1042
        }
1043
        if( 0 >= count( $result )) return FALSE;
1044
        elseif( !$flat ) {