Skip to content

Commit

Permalink
Fix ical file parser issues and CSS overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
jbardo-godaddy committed Oct 14, 2021
1 parent 46d2172 commit 5498759
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 39 deletions.
18 changes: 8 additions & 10 deletions includes/ical-parser/class-coblocks-ical.php
Expand Up @@ -1813,8 +1813,6 @@ function ( $exdate ) use ( $an_event, $monthrecurring_offset ) {
$event_start_timestamp += self::SECONDS_IN_A_WEEK;
} while ( $event_start_timestamp <= $last_day_time_stamp );

// Move forwards
// $recurring_timestamp = strtotime($offset, Carbon::createFromTimestamp($recurring_timestamp)->day(1)->timestamp);
}
}

Expand Down Expand Up @@ -2338,7 +2336,7 @@ protected function is_valid_iana_timezone_id( $timezone ) {

unset( $valid[''] );

if ( isset( $valid[ $timezone ] ) || in_array( $timezone, timezone_identifiers_list( \date_timezone::ALL_WITH_BC ), true ) ) {
if ( isset( $valid[ $timezone ] ) || in_array( $timezone, timezone_identifiers_list( \DateTimeZone::ALL_WITH_BC ), true ) ) {
$this->valid_iana_timezones[] = $timezone;

return true;
Expand Down Expand Up @@ -2371,7 +2369,7 @@ public function is_valid_windows_timezone_id( $timezone ) {
* Parses a duration and applies it to a date
*
* @param string $date
* @param string $duration
* @param object $duration
* @param string $format
* @return integer|\DateTime
*/
Expand Down Expand Up @@ -2628,7 +2626,7 @@ public function parse_ex_dates( array $event ) {
$current_time_zone = self::TIME_ZONE_UTC;
}

$output[] = new \DateTime( $ical_date, $current_time_zone );
$output[] = new \DateTime( $ical_date, new \DateTimeZone( $current_time_zone ) );

if ( $key === $final_key ) {
// Reset to default
Expand Down Expand Up @@ -2766,7 +2764,7 @@ protected function trim_to_recurrence_count( array $rrules, array $recurrence_ev
/**
* Checks if an excluded date matches a given date by reconciling time zones.
*
* @param Carbon $exdate
* @param DateTime $exdate
* @param array $an_event
* @param integer $recurring_offset
* @return boolean
Expand All @@ -2775,16 +2773,16 @@ protected function is_ex_date_match( $exdate, array $an_event, $recurring_offset
$search_date = $an_event['DTSTART'];

if ( substr( $search_date, -1 ) === 'Z' ) {
$timezone = self::TIME_ZONE_UTC;
$timezone = new \DateTimeZone(self::TIME_ZONE_UTC);
} elseif ( isset( $an_event['DTSTART_array'][0]['TZID'] ) ) {
$timezone = $this->timezone_string_to_date_timezone( $an_event['DTSTART_array'][0]['TZID'] );
} else {
$timezone = $this->default_time_zone;
$timezone = new \DateTimeZone($this->default_time_zone);
}

$a = new \DateTime( $search_date, $timezone );
$b = $exdate->addSeconds( $recurring_offset );
$b = $exdate->add( \DateInterval::createFromDateString( $recurring_offset . ' seconds' ) );

return $a->eq( $b );
return $a == $b;
}
}
28 changes: 19 additions & 9 deletions src/blocks/events/edit.js
Expand Up @@ -148,16 +148,26 @@ const EventsEdit = ( props ) => {
<Placeholder
icon="rss"
label={ __( 'Calendar URL', 'coblocks' ) }
instructions={ __(
'Enter a URL that loads and iCal formatted calendar.',
'coblocks'
) }
>
<TextControl
placeholder={ __( 'Enter URL here…', 'coblocks' ) }
value={ stateExternalCalendarUrl }
onChange={ ( newExternalCalendarUrl ) => setStateExternalCalendarUrl( newExternalCalendarUrl ) }
className={ 'components-placeholder__input' }
/>
<Button type="button" onClick={ saveExternalCalendarUrl } disabled={ ! stateExternalCalendarUrl }>
{ __( 'Use URL', 'coblocks' ) }
</Button>
<form onSubmit={ saveExternalCalendarUrl }>
<TextControl
className={ 'components-placeholder__input' }
onChange={ ( newExternalCalendarUrl ) => setStateExternalCalendarUrl( newExternalCalendarUrl ) }
placeholder={ __( 'Enter URL here…', 'coblocks' ) }
value={ stateExternalCalendarUrl }
/>
<Button
disabled={ ! stateExternalCalendarUrl }
isPrimary
type="submit"
>
{ __( 'Use URL', 'coblocks' ) }
</Button>
</form>
</Placeholder>
}

Expand Down
2 changes: 2 additions & 0 deletions src/blocks/events/styles/editor.scss
@@ -1,5 +1,7 @@
[data-type="coblocks/events"] {

@include input-submit-placeholder;

.coblocks-block-appender {
margin-top: 28px;
}
Expand Down
21 changes: 1 addition & 20 deletions src/blocks/map/styles/editor.scss
@@ -1,25 +1,6 @@
[data-type="coblocks/map"] {

.components-placeholder {
height: 100%;

.components-placeholder__fieldset {

.components-placeholder__input {
margin-right: 5px;
min-width: 50%;

.components-base-control__field {
height: 36px;
margin-right: 8px;
}
}

input {
height: 36px;
}
}

@include input-submit-placeholder {
.components-placeholder__label {

svg {
Expand Down
24 changes: 24 additions & 0 deletions src/styles/mixins.scss
Expand Up @@ -40,3 +40,27 @@
@content;
}
}
@mixin input-submit-placeholder {
.components-placeholder {
height: 100%;

.components-placeholder__fieldset {

.components-placeholder__input {
margin-right: 5px;
min-width: 50%;

.components-base-control__field {
height: 36px;
margin-right: 8px;
}
}

input {
height: 36px;
}
}

@content;
}
}

0 comments on commit 5498759

Please sign in to comment.