class ICal (View source)

Class to read/parse ICal calendars

Properties

string $file
string $file_text
array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>> $cal
int $event_count
int $todo_count
int $freebusy_count
string $last_key
string $error

Methods

__construct()

Constructor

string|null
read_file($file)

Read text file, icalender text file

int
get_event_count()

Returns the number of calendar events

int
get_todo_count()

Returns the number of to do

string|array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>>
parse(string $uri, string $usecachefile = '', int $delaycache = 3600)

Translate Calendar

void
add_to_array(string $type, string $key, string $value)

Add to $this->ical array one value and key.

array{0: string, 1: string}
retun_key_value(string $text)

Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value");

array<string, string>
ical_rrule(string $value)

Parse RRULE return array

int
ical_date_to_unix(string $ical_date)

Return Unix time from ical date time format (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS)

array{0: string, 1: int}|array{0: string, 1: array<string, int|string>}
ical_dt_date(string $key, string $value)

Return unix date from iCal date format

array<int, array<string, string>>|false
get_sort_event_list()

Return sorted eventlist as array or false if calendar is empty

int
ical_dtstart_compare(array{DTSTART: array{unixtime: string}} $a, array{DTSTART: array{unixtime: string}} $b)

Compare two unix timestamp

array<int, array<string, string>>
get_event_list()

Return eventlist array (not sorted eventlist array)

array<int, array<string, string>>
get_freebusy_list()

Return freebusy array (not sort eventlist array)

array<int, array<string, string>>
get_todo_list()

Return to do array (not sorted todo array)

array<int, array<string, string>>
get_calender_data()

Return base calendar data

array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>>
get_all_data()

Return array with all data

Details

__construct()

Constructor

string|null read_file($file)

Read text file, icalender text file

@param string $file File

Parameters

$file

Return Value

string|null

Content of remote file read or null if error

int get_event_count()

Returns the number of calendar events

Return Value

int

int get_todo_count()

Returns the number of to do

Return Value

int

string|array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>> parse(string $uri, string $usecachefile = '', int $delaycache = 3600)

Translate Calendar

Parameters

string $uri Url
string $usecachefile

Full path of a cache file to use a cache file

int $delaycache

Delay in seconds for cache (by default 3600 secondes)

Return Value

string|array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>>

void add_to_array(string $type, string $key, string $value)

Add to $this->ical array one value and key.

Parameters

string $type

Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...)

string $key

Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property

string $value Value

Return Value

void

array{0: string, 1: string} retun_key_value(string $text)

Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value");

Parameters

string $text Text

Return Value

array{0: string, 1: string}

array<string, string> ical_rrule(string $value)

Parse RRULE return array

Parameters

string $value string

Return Value

array<string, string>

int ical_date_to_unix(string $ical_date)

Return Unix time from ical date time format (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS)

Parameters

string $ical_date

String date

Return Value

int

array{0: string, 1: int}|array{0: string, 1: array<string, int|string>} ical_dt_date(string $key, string $value)

Return unix date from iCal date format

Parameters

string $key

Key. Example: 'DTSTART', 'DTSTART;TZID=US-Eastern'

string $value

Value. Example: '19970714T133000', '19970714T173000Z', '19970714T133000'

Return Value

array{0: string, 1: int}|array{0: string, 1: array<string, int|string>}

array<int, array<string, string>>|false get_sort_event_list()

Return sorted eventlist as array or false if calendar is empty

Return Value

array<int, array<string, string>>|false

int ical_dtstart_compare(array{DTSTART: array{unixtime: string}} $a, array{DTSTART: array{unixtime: string}} $b)

Compare two unix timestamp

Parameters

array{DTSTART: array{unixtime: string}} $a

Operand a

array{DTSTART: array{unixtime: string}} $b

Operand b

Return Value

int

array<int, array<string, string>> get_event_list()

Return eventlist array (not sorted eventlist array)

Return Value

array<int, array<string, string>>

array<int, array<string, string>> get_freebusy_list()

Return freebusy array (not sort eventlist array)

Return Value

array<int, array<string, string>>

array<int, array<string, string>> get_todo_list()

Return to do array (not sorted todo array)

Return Value

array<int, array<string, string>>

array<int, array<string, string>> get_calender_data()

Return base calendar data

Return Value

array<int, array<string, string>>

array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>> get_all_data()

Return array with all data

Return Value

array<string, array<"VEVENT"|"VFREEBUSY"|"VTODO", array<int, array<string, string>>>>|array<string, array<int, array<string, array<string, int>>>>|array<string, array<int, array<string, int>>>|array<string, array<int, array<string, string>>>