PHP Class ICal\ICal

Datei anzeigen Open project: johngrogg/ics-parser Class Usage Examples

Public Properties

Property Type Description
$cal array The parsed calendar
$defaultSpan integer The value in years to use for indefinite, recurring events
$defaultWeekStart
$eventCount integer How many events are in this iCal?
$freebusyCount integer How many freebusy are in this iCal?
$todoCount integer How many ToDos are in this iCal?

Protected Properties

Property Type Description
$alteredRecurrenceInstances array Event recurrence instances that have been altered
$dayOrdinals
$frequencyConversion
$monthNames
$weekdays

Public Methods

Method Description
__construct ( mixed $filename = false, mixed $weekStart = false ) : void Creates the iCal Object
calendarDescription ( ) : calendar Returns the calendar description
calendarName ( ) : string Returns the calendar name
calendarTimeZone ( ) : calendar Returns the calendar timezone
events ( ) : array Returns an array of EventObjects. Every event is a class with the event details being properties within it.
eventsFromInterval ( string $interval ) : array Returns a sorted array of the events following a given string, or false if no events exist in the range.
eventsFromRange ( string $rangeStart = false, string $rangeEnd = false ) : array Returns a sorted array of the events in a given range, or false if no events exist in the range.
freeBusyEvents ( ) : array Returns an array of arrays with all free/busy events. Every event is an associative array and each property is an element it.
hasEvents ( ) : boolean Returns a boolean value whether the current calendar has events or not
iCalDateToUnixTimestamp ( string $icalDate ) : integer Return Unix timestamp from iCal date time format
iCalDateWithTimeZone ( array $event, string $key ) : string Return a date adapted to the calendar timezone depending on the event TZID
initLines ( array $lines ) : ICal Initialises lines from file
initString ( string $contents ) : ICal Initialises lines from a string
initURL ( string $url ) : ICal Initialises lines from a URL
isValidTimeZoneId ( string $timezone ) : boolean Check if a timezone is valid
processDateConversions ( ) : void Processes date conversions using the timezone
processEvents ( ) : void Performs some admin tasks on all events as taken straight from the ics file.
processRecurrences ( ) : void Processes recurrence rules
sortEventsWithOrder ( array $events, integer $sortOrder = SORT_ASC ) : sorted Sort events based on a given sort order

Protected Methods

Method Description
addCalendarComponentWithKeyAndValue ( string $component, string | boolean $keyword, string $value ) : void Add to $this->ical array one value and key.
keyValueFromString ( string $text ) : array Get a key-value pair of a string.

Method Details

__construct() public method

Creates the iCal Object
public __construct ( mixed $filename = false, mixed $weekStart = false ) : void
$filename mixed The path to the iCal-file or an array of lines from an iCal file
$weekStart mixed The default first day of the week (SU or MO, etc.)
return void or false if no filename is provided

addCalendarComponentWithKeyAndValue() protected method

Add to $this->ical array one value and key.
protected addCalendarComponentWithKeyAndValue ( string $component, string | boolean $keyword, string $value ) : void
$component string This could be VTODO, VEVENT, VCALENDAR, ...
$keyword string | boolean The keyword, for example DTSTART
$value string The value, for example 20110105T090000Z
return void

calendarDescription() public method

Returns the calendar description
public calendarDescription ( ) : calendar
return calendar description

calendarName() public method

Returns the calendar name
public calendarName ( ) : string
return string

calendarTimeZone() public method

Returns the calendar timezone
public calendarTimeZone ( ) : calendar
return calendar timezone

events() public method

Returns an array of EventObjects. Every event is a class with the event details being properties within it.
public events ( ) : array
return array of EventObjects

eventsFromInterval() public method

Returns a sorted array of the events following a given string, or false if no events exist in the range.
public eventsFromInterval ( string $interval ) : array
$interval string
return array of EventObjects

eventsFromRange() public method

Events will be returned if the start or end date is contained within the range (inclusive), or if the event starts before and end after the range. If a start date is not specified or of a valid format, then the start of the range will default to the current time and date of the server. If an end date is not specified or of a valid format, the the end of the range will default to the current time and date of the server, plus 20 years. Note that this function makes use of UNIX timestamps. This might be a problem for events on, during, or after January the 29th, 2038. See http://en.wikipedia.org/wiki/Unix_time#Representing_the_number
public eventsFromRange ( string $rangeStart = false, string $rangeEnd = false ) : array
$rangeStart string Start date of the search range.
$rangeEnd string End date of the search range.
return array of EventObjects

freeBusyEvents() public method

Returns an array of arrays with all free/busy events. Every event is an associative array and each property is an element it.
public freeBusyEvents ( ) : array
return array

hasEvents() public method

Returns a boolean value whether the current calendar has events or not
public hasEvents ( ) : boolean
return boolean

iCalDateToUnixTimestamp() public method

Return Unix timestamp from iCal date time format
public iCalDateToUnixTimestamp ( string $icalDate ) : integer
$icalDate string A Date in the format YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS or TZID=Timezone:YYYYMMDD[T]HHMMSS
return integer

iCalDateWithTimeZone() public method

Return a date adapted to the calendar timezone depending on the event TZID
public iCalDateWithTimeZone ( array $event, string $key ) : string
$event array an event
$key string an event parameter (DTSTART or DTEND)
return string Ymd\THis date

initLines() public method

Initialises lines from file
public initLines ( array $lines ) : ICal
$lines array The lines to initialise
return ICal

initString() public method

Initialises lines from a string
public initString ( string $contents ) : ICal
$contents string The contents of the ical file to initialise
return ICal

initURL() public method

Initialises lines from a URL
public initURL ( string $url ) : ICal
$url string The url of the ical file to download and initialise
return ICal

isValidTimeZoneId() public method

Check if a timezone is valid
public isValidTimeZoneId ( string $timezone ) : boolean
$timezone string A timezone
return boolean

keyValueFromString() protected method

Get a key-value pair of a string.
protected keyValueFromString ( string $text ) : array
$text string which is like "VCALENDAR:Begin" or "LOCATION:"
return array

processDateConversions() public method

Add fields DTSTART_tz and DTEND_tz to each event These fields contain dates adapted to the calendar timezone depending on the event TZID
public processDateConversions ( ) : void
return void or false if no Events exist

processEvents() public method

Adds a unix timestamp to all DT{START|END|RECURRENCE-ID}_array arrays Makes a note of modified recurrence-instances
public processEvents ( ) : void
return void or false if no Events exist

processRecurrences() public method

Processes recurrence rules
public processRecurrences ( ) : void
return void or false if no Events exist

sortEventsWithOrder() public method

Sort events based on a given sort order
public sortEventsWithOrder ( array $events, integer $sortOrder = SORT_ASC ) : sorted
$events array An array of EventObjects
$sortOrder integer Either SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING
return sorted array of EventObjects

Property Details

$alteredRecurrenceInstances protected_oe property

Event recurrence instances that have been altered
protected array $alteredRecurrenceInstances
return array

$cal public_oe property

The parsed calendar
public array $cal
return array

$dayOrdinals protected_oe property

protected $dayOrdinals

$defaultSpan public_oe property

The value in years to use for indefinite, recurring events
public int $defaultSpan
return integer

$defaultWeekStart public_oe property

public $defaultWeekStart

$eventCount public_oe property

How many events are in this iCal?
public int $eventCount
return integer

$freebusyCount public_oe property

How many freebusy are in this iCal?
public int $freebusyCount
return integer

$frequencyConversion protected_oe property

protected $frequencyConversion

$monthNames protected_oe property

protected $monthNames

$todoCount public_oe property

How many ToDos are in this iCal?
public int $todoCount
return integer

$weekdays protected_oe property

protected $weekdays