PHP Class Horde_Icalendar, horde

Author: Mike Cochrane ([email protected])
Mostra file Open project: horde/horde Class Usage Examples

Public Properties

Property Type Description
$type string The component type of this class.

Protected Properties

Property Type Description
$_attributes array The name/value pairs of attributes for this object (UID, DTSTART, etc.). Which are present depends on the object and on what kind of component it is.
$_components array Any children (contained) iCalendar components of this object.
$_container Horde_Icalendar The parent (containing) iCalendar object.
$_newline string According to RFC 2425, we should always use CRLF-terminated lines.
$_oldFormat These 'old' formats are defined by www.imc.org. The 'new' (non-old) formats icalendar 2.0 and vcard 3.0 are defined in rfc2426 and rfc2445 respectively.
$_version string iCalendar format version (different behavior for 1.0 and 2.0 especially with recurring events).

Public Methods

Method Description
__construct ( $version = '2.0' ) Constructor.
_exportDateTime ( integer | object | array $value, boolean $floating = false ) : string Export a DateTime field.
_exportUtcOffset ( $value ) : TODO Export a UTC Offset field.
_parseDate ( $text ) : array Parses a Date field.
_parseDateTime ( $text, $tzid = false ) : TODO Parses a DateTime field and returns a unix timestamp. If the field cannot be parsed then the original text is returned unmodified.
addComponent ( $components ) Add a vCalendar component (eg vEvent, vTimezone, etc.).
clear ( ) Clears the iCalendar object (resets the components and attributes arrays).
exportvCalendar ( ) : TODO Export as vCalendar format.
findComponent ( $childclass ) : boolean | Horde_Icalendar_ Locates the first child component of the specified class, and returns a reference to it.
findComponentByAttribute ( string $childclass, string $attribute, string $value = null ) : boolean | Horde_Icalendar_ Locates the first matching child component of the specified class, and returns a reference to it.
getAllAttributes ( string $tag = false ) : array Get attributes for all tags or for a given tag.
getAttribute ( string $name, boolean $params = false ) : mixed Get the value of an attribute.
getAttributeDefault ( string $name, mixed $default = '' ) : mixed Returns the value of an attribute, or a specified default value if the attribute does not exist.
getAttributeSingle ( string $name ) : string Get a single value of an attribute.
getAttributeValues ( string $name ) : array Gets the values of an attribute as an array. Multiple values are possible due to:
getComponent ( integer $idx ) : mixed Retrieve a specific component.
getComponentClasses ( ) : array Return the classes (entry types) we have.
getComponentCount ( ) : integer Number of components in this container.
getComponents ( ) : array Retrieve all the components.
getType ( ) : TODO TODO
newComponent ( string $type, Horde_Icalendar $container ) : object Return a reference to a new component.
parsevCalendar ( string $text, string $base = 'VCALENDAR', boolean $clear = true ) : boolean Parses a string containing vCalendar data.
removeAttribute ( string $name ) Remove all occurences of an attribute.
setAttribute ( string $name, string $value, array $params = [], boolean $append = true, array $values = false ) Sets the value of an attribute.
setParameter ( string $name, array $params = [] ) : boolean Sets parameter(s) for an (already existing) attribute. The parameter set is merged into the existing set.
setVersion ( string $version ) Sets the version of this component.
toHash ( boolean $paramsInKeys = false ) : array Export this entry as a hash array with tag names as keys.
toString ( )

Protected Methods

Method Description
_checkEndDate ( integer $t, array $times ) : boolean Utility method to aid in checking the end date of a transition.
_exportDate ( object | array $value, string $autoconvert = false ) : TODO Exports a date field.
_exportDuration ( $value ) Export a duration value.
_exportPeriod ( $value ) : TODO Export a Time Period field.
_exportvData ( string $base = 'VCALENDAR' ) : string Export this component in vCal format.
_parseDuration ( string $text ) : integer Parses a DURATION value field.
_parsePeriod ( $text ) : array Parse a Time Period field.
_parseTZID ( array $date, array $time, string $tzid ) : integer Groks the TZID and returns an offset in seconds from UTC for this date and time.
_parseTime ( $text ) : TODO Parses a Time field.
_parseUtcOffset ( $text ) : TODO Parse a UTC Offset field.

Method Details

__construct() public method

Constructor.
public __construct ( $version = '2.0' )

_checkEndDate() protected method

Utility method to aid in checking the end date of a transition.
protected _checkEndDate ( integer $t, array $times ) : boolean
$t integer The timestamp of the date we are checking.
$times array A transition array.
return boolean True if $t is before the end date of the transition otherwise false.

_exportDate() protected method

Exports a date field.
protected _exportDate ( object | array $value, string $autoconvert = false ) : TODO
$value object | array Date object or hash.
$autoconvert string If set, use this as time part to export the date as datetime when exporting to Vcalendar 1.0. Examples: '000000' or '235959'
return TODO

_exportDateTime() public method

Export a DateTime field.
public _exportDateTime ( integer | object | array $value, boolean $floating = false ) : string
$value integer | object | array The time value to export (either a Horde_Date, array, or timestamp).
$floating boolean Whether to return a floating date-time (without time zone information).
return string The string representation of the datetime value.

_exportDuration() protected method

Export a duration value.
protected _exportDuration ( $value )
$value TODO

_exportPeriod() protected method

Export a Time Period field.
protected _exportPeriod ( $value ) : TODO
$value TODO
return TODO

_exportUtcOffset() public method

Export a UTC Offset field.
public _exportUtcOffset ( $value ) : TODO
$value TODO
return TODO

_exportvData() protected method

Export this component in vCal format.
protected _exportvData ( string $base = 'VCALENDAR' ) : string
$base string The type of the base object.
return string vCal format data.

_parseDate() public method

Parses a Date field.
public _parseDate ( $text ) : array
$text TODO
return array TODO

_parseDateTime() public method

Parses a DateTime field and returns a unix timestamp. If the field cannot be parsed then the original text is returned unmodified.
public _parseDateTime ( $text, $tzid = false ) : TODO
$tzid TODO
return TODO

_parseDuration() protected method

Parses a DURATION value field.
protected _parseDuration ( string $text ) : integer
$text string A DURATION value.
return integer The duration in seconds.

_parsePeriod() protected method

Parse a Time Period field.
protected _parsePeriod ( $text ) : array
$text TODO
return array TODO

_parseTZID() protected method

Groks the TZID and returns an offset in seconds from UTC for this date and time.
protected _parseTZID ( array $date, array $time, string $tzid ) : integer
$date array A date hash.
$time array A time hash.
$tzid string A timezone ID.
return integer The offset from UTC in seconds for the provided timezone and date/time.

_parseTime() protected method

Parses a Time field.
protected _parseTime ( $text ) : TODO
$text TODO
return TODO

_parseUtcOffset() protected method

Parse a UTC Offset field.
protected _parseUtcOffset ( $text ) : TODO
$text TODO
return TODO

addComponent() public method

Add a vCalendar component (eg vEvent, vTimezone, etc.).
public addComponent ( $components )

clear() public method

Clears the iCalendar object (resets the components and attributes arrays).
public clear ( )

exportvCalendar() public method

Export as vCalendar format.
public exportvCalendar ( ) : TODO
return TODO

findComponent() public method

Locates the first child component of the specified class, and returns a reference to it.
public findComponent ( $childclass ) : boolean | Horde_Icalendar_
return boolean | Horde_Icalendar_

findComponentByAttribute() public method

Locates the first matching child component of the specified class, and returns a reference to it.
public findComponentByAttribute ( string $childclass, string $attribute, string $value = null ) : boolean | Horde_Icalendar_
$childclass string The type of component to find.
$attribute string This attribute must be set in the component for it to match.
$value string Optional value that $attribute must match.
return boolean | Horde_Icalendar_

getAllAttributes() public method

Get attributes for all tags or for a given tag.
public getAllAttributes ( string $tag = false ) : array
$tag string Return attributes for this tag, or all attributes if not given.
return array An array containing all the attributes and their types.

getAttribute() public method

Get the value of an attribute.
public getAttribute ( string $name, boolean $params = false ) : mixed
$name string The name of the attribute.
$params boolean Return the parameters for this attribute instead of its value.
return mixed (string) The value of the attribute. (array) The parameters for the attribute or multiple values for an attribute.

getAttributeDefault() public method

Returns the value of an attribute, or a specified default value if the attribute does not exist.
public getAttributeDefault ( string $name, mixed $default = '' ) : mixed
$name string The name of the attribute.
$default mixed What to return if the attribute specified by $name does not exist.
return mixed (mixed) The value of $name. (mixed) $default if $name does not exist.

getAttributeSingle() public method

If multiple values, is auto-determined by library which is preferred value to return.
Since: 2.1.0
public getAttributeSingle ( string $name ) : string
$name string The name of the attribute.
return string The value of the attribute.

getAttributeValues() public method

a) multiple occurences of 'name' b) (unsecapd) comma seperated lists. So for a vcard like "KEY:a,b\nKEY:c" getAttributesValues('KEY') will return array('a', 'b', 'c').
public getAttributeValues ( string $name ) : array
$name string The name of the attribute.
return array Multiple values for an attribute.

getComponent() public method

Retrieve a specific component.
public getComponent ( integer $idx ) : mixed
$idx integer The index of the object to retrieve.
return mixed (boolean) False if the index does not exist. (Horde_Icalendar_*) The requested component.

getComponentClasses() public method

Return the classes (entry types) we have.
public getComponentClasses ( ) : array
return array Hash with class names Horde_Icalendar_xxx as keys and number of components of this class as value.

getComponentCount() public method

Number of components in this container.
public getComponentCount ( ) : integer
return integer Number of components in this container.

getComponents() public method

Retrieve all the components.
public getComponents ( ) : array
return array Array of Horde_Icalendar objects.

getType() public method

TODO
public getType ( ) : TODO
return TODO

newComponent() public static method

Return a reference to a new component.
public static newComponent ( string $type, Horde_Icalendar $container ) : object
$type string The type of component to return
$container Horde_Icalendar A container that this component will be associated with.
return object Reference to a Horde_Icalendar_* object as specified.

parsevCalendar() public method

Parses a string containing vCalendar data.
public parsevCalendar ( string $text, string $base = 'VCALENDAR', boolean $clear = true ) : boolean
$text string The data to parse.
$base string The type of the base object.
$clear boolean If true clears this object before parsing.
return boolean True on successful import, false otherwise.

removeAttribute() public method

Remove all occurences of an attribute.
public removeAttribute ( string $name )
$name string The name of the attribute.

setAttribute() public method

Sets the value of an attribute.
public setAttribute ( string $name, string $value, array $params = [], boolean $append = true, array $values = false )
$name string The name of the attribute.
$value string The value of the attribute.
$params array Array containing any addition parameters for this attribute.
$append boolean True to append the attribute, False to replace the first matching attribute found.
$values array Array representation of $value. For comma/semicolon seperated lists of values. If not set use $value as single array element.

setParameter() public method

Sets parameter(s) for an (already existing) attribute. The parameter set is merged into the existing set.
public setParameter ( string $name, array $params = [] ) : boolean
$name string The name of the attribute.
$params array Array containing any additional parameters for this attribute.
return boolean True on success, false if no attribute $name exists.

setVersion() public method

Sets the version of this component.
public setVersion ( string $version )
$version string A float-like version string.

toHash() public method

Export this entry as a hash array with tag names as keys.
public toHash ( boolean $paramsInKeys = false ) : array
$paramsInKeys boolean If false, the operation can be quite lossy as the parameters are ignored when building the array keys. So if you export a vcard with LABEL;TYPE=WORK:foo LABEL;TYPE=HOME:bar the resulting hash contains only one label field! If set to true, array keys look like 'LABEL;TYPE=WORK'
return array A hash array with tag names as keys.

toString() public method

public toString ( )

Property Details

$_attributes protected_oe property

The name/value pairs of attributes for this object (UID, DTSTART, etc.). Which are present depends on the object and on what kind of component it is.
protected array $_attributes
return array

$_components protected_oe property

Any children (contained) iCalendar components of this object.
protected array $_components
return array

$_container protected_oe property

The parent (containing) iCalendar object.
protected Horde_Icalendar $_container
return Horde_Icalendar

$_newline protected_oe property

According to RFC 2425, we should always use CRLF-terminated lines.
protected string $_newline
return string

$_oldFormat protected_oe property

These 'old' formats are defined by www.imc.org. The 'new' (non-old) formats icalendar 2.0 and vcard 3.0 are defined in rfc2426 and rfc2445 respectively.
protected $_oldFormat

$_version protected_oe property

iCalendar format version (different behavior for 1.0 and 2.0 especially with recurring events).
protected string $_version
return string

$type public_oe property

The component type of this class.
public string $type
return string