EO_ICAL_Parser
Parses a local or remote ICAL file
Example usage
$ical = new EO_ICAL_Parser();
$ical->parse( 'http://www.dol.govt.nz/er/holidaysandleave/publicholidays/publicholidaydates/ical/auckland.ics' );
$ical->events;
$ical->venues;
$ical->categories;
$ical->errors;
$ical->warnings;
You can configire default settings by passing an array to the class constructor.
$ical = new EO_ICAL_Parser( array( ..., 'default_status' => 'published', ... ) );
Available settings include:
- status_map - How to interpret the ICAL STATUS property.
- default_status - Default status of posts (unless otherwise specified by STATUS). Default is 'draft'
Methods
public |
#
__construct( $args )
Constructor with settings passed as arguments Available options include 'status_map' and 'default_status'.
|
public |
#
parse( $file )
Parses the given $file. Returns WP_Error on error.
|
protected |
#
url_to_array( $url )
Fetches ICAL calendar from a feed url and returns its contents as an array.
|
protected |
#
file_to_array( $file )
Fetches ICAL calendar from a file and returns its contents as an array.
|
public |
#
unfold_lines( $lines )
Modifies the ical_array to unfold multi-line entries into a single line.
Preserves the original line numbering so that line numbers in error messages
match up with the line numbers when viewing the (unfolded) iCal file in a
text editor.
|
protected |
#
parse_ical_array( )
Parses through an array of lines (of an ICAL file)
|
protected |
#
report_error( $line, $type, $message )
Report an error with an iCal file
|
protected |
#
report_warning( $line, $type, $message )
Report an warnings with an iCal file
|
protected |
#
parse_event_property( $property, $value, $modifiers )
|
protected |
#
parse_ical_html( $text )
|
public |
#
parse_ical_text( $text )
Takes escaped text and returns the text unescaped.
|
public |
#
parse_timezone( $tzid )
Takes a date-time in ICAL and returns a datetime object
|
public |
#
parse_ical_date( $ical_date )
Takes a date in ICAL and returns a datetime object
Expects date in yyyymmdd format
|
public |
#
parse_ical_datetime( $ical_date, $tz )
Takes a date-time in ICAL and returns a datetime object
It returns the datetime in the specified
Expects
- utc: YYYYMMDDTHHiissZ
- local: YYYYMMDDTHHiiss
|
public |
#
parse_duration( $duration_str )
|
public |
#
parse_RRule( $RRule )
Takes a date-time in ICAL and returns a datetime object
|
public |
#
_split_line( $line )
Responsible for splitting an iCal line into Property and Value
E.g. BEGIN:VEVENT to BEGIN and VEVENT . Special care needs to be taken
when dealing with values such as DTSTART;TZID="(GMT +01:00)":20140712T100000
|
Properties
public
|
$events
|
Array of events present in the feed
|
public
|
$venues
|
Array of venues present in the feed
|
public
|
$venue_meta
|
Array of venue metadata present in the feed
|
public
|
$categories
|
Array of categories present in the feed
|
public
|
$events_parsed
|
Number of events parsed.
|
public
|
$venue_parsed
|
Number of venues parsed.
|
public
|
$categories_parsed
|
Number of categories parsed.
|
public
|
$remote_timeout
|
Timeout for remote fetching (in seconds)
|
public
|
$errors
|
Array of WP_Error objects. These are errors which abort the parsing.
|
public
|
$warnings
|
Array of WP_Error objects. These are soft-errors which the parser tries to deal with
|
public
|
$current_event
|
The current event being parsed. Stores data retrieved so far in the parsing.
|
public
|
$line
|
Indicates which line in the feed we are at
|
public
|
$state
|
Keeps track of where we are in the feed.
|
public
|
$parse_html
|
Option to toggle whether a HTML description should be used (if present).
|
Hooks
Resources