Fix for white space
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 15 Aug 2016 12:28:05 +0000 (08:28 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 15 Aug 2016 12:28:05 +0000 (08:28 -0400)
Add white spacing for readability and for wordpress coding standands.

models/front/events/icalFeedImport.php

index c4cfb11..31a6173 100644 (file)
@@ -275,7 +275,6 @@ class GlmMembersFront_events_icalFeedImport
                 if ( isset( $event['RRULE'] ) ) {
                     $recurring_event = 1;
                     $rrule_data = explode( ';', $event['RRULE'] );
-                    //echo '<pre>$rrule_data: ' . print_r( $rrule_data, true ) . '</pre>';
                     if ( $rrule_data ) {
                         foreach ( $rrule_data as $rule ) {
                             if ( preg_match( '%FREQ=(.*)%', $rule, $matches ) ) {
@@ -289,39 +288,37 @@ class GlmMembersFront_events_icalFeedImport
                             }
                         }
                     }
-                    if ( $freq === 'WEEKLY' && $byday ) {
+                    if ( ( $freq === 'WEEKLY' || $freq === 'MONTHLY' ) && $byday ) {
                         // separated by commas
-                        $days = explode( ',',$byday );
-                        //echo '<pre>$days: ' . print_r( $days, true ) . '</pre>';
+                        $days = explode( ',', $byday );
                         if ( $days ) {
                             $day_of_week = 0;
                             foreach ( $days as $day ) {
-                                if ( preg_match( '%([0-9])?([A-Z]{2})%', $day, $d_matches ) ) {
-                                    //echo '<pre>$d_matches: ' . print_r( $d_matches, true ) . '</pre>';
+                                if ( preg_match( '%([0-9]*)?([A-Z]{2})%', $day, $d_matches ) ) {
                                     if ( $d_matches[1] ) {
-                                        $week_of_month = pow(2, $d_matches[1] );
+                                        $week_of_month = pow( 2, (int)$d_matches[1] );
                                     }
                                     switch ( $d_matches[2] ) {
                                     case "SU":
-                                        $day_of_week += pow(2, 0);
+                                        $day_of_week += pow( 2, 0 );
                                         break;
                                     case "MO":
-                                        $day_of_week += pow(2, 1);
+                                        $day_of_week += pow( 2, 1 );
                                         break;
                                     case "TU":
-                                        $day_of_week += pow(2, 2);
+                                        $day_of_week += pow( 2, 2 );
                                         break;
                                     case "WE":
-                                        $day_of_week += pow(2, 3);
+                                        $day_of_week += pow( 2, 3 );
                                         break;
                                     case "TH":
-                                        $day_of_week += pow(2, 4);
+                                        $day_of_week += pow( 2, 4 );
                                         break;
                                     case "FR":
-                                        $day_of_week += pow(2, 5);
+                                        $day_of_week += pow( 2, 5 );
                                         break;
                                     case "SA":
-                                        $day_of_week += pow(2, 6);
+                                        $day_of_week += pow( 2, 6 );
                                         break;
                                     }
                                 }
@@ -329,12 +326,10 @@ class GlmMembersFront_events_icalFeedImport
                         }
                     }
                     if ( $until != '' ) {
-                        //echo '<pre>$until: ' . print_r( $until, true ) . '</pre>';
                         $test_date = $ical->iCalDateToUnixTimestamp( $until );
                         if ( $test_date ) {
                             $to_date = date( 'Y-m-d', $test_date );
                         }
-                        //echo '<pre>$test_date: ' . print_r( date( 'm/d/Y', $test_date), true ) . '</pre>';
                     }
                 }
                 if ( $btime === $etime ) {