Class: vCal

  • Package: saf.Date
  • Author: John Luxford <lux@simian.ca>
  • Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
  • License: http://www.sitellite.org/index/license Simian Open Software License
  • Version: 1.2, 2002-09-25, $Id: vCalendar.php,v 1.3 2007/10/06 00:06:30 lux Exp $
  • Access: public

vCal implements a basic parser and mechanism for generating vCalendar
and iCalendar messages. Knowledge of the names and meanings of the
properties available to each message type will be required, as this
class does nothing to manage those.

New in 1.2:
- Added some compatibility improvements which allow vCal to also support
the vCard format, as well as all of the event types.
- Note: There is a problem with Apple's Address Book, which I am testing
against. It does not properly unfold a vCard, so if a name is on the
following line (using the CRLF plus a space syntax defined in the specs)
it will be imported with no name. Fortunately for us vCal coders,
a workaround is to wrap your write() call in an unfold() call,
although this will remove all occurrences of CRLF + space and could
cause long lines which might not work with some vCalendar/vCard
applications.


Usage Example


<?php

$cal 
= new vCal ();

$cal->addProperty ('VERSION''2.0');
$cal->addProperty ('PRODID''-//Simian Systems//NONSGML Sitellite Application Framework//EN');

$event =& $cal->addEvent ('VEVENT');

$event->addProperty ('UID'54321);
$event->addProperty ('ORGANIZER''MAILTO:bananaman@simian.ca');
$prop =& $event->addProperty ('ATTENDEE''MAILTO:bananaman@simian.ca');
$prop->addParameter ('RSVP''TRUE');

// start time is now
$event->addProperty ('DTSTART'date ('Ymd\THis\Z'));

// end time is the same time tomorrow
$event->addProperty ('DTEND'date ('Ymd\THis\Z'time () + 86400));

$event->addProperty ('SUMMARY''Party time!');
$event->addProperty ('LOCATION''My place');

echo 
$cal->write ();

?>

Return to Top



Properties


$dayLinks = false

  • Access: public

Link pattern for days.


$showPeriod

  • Access: public

Tells the calendar what to display on a single screen. May be
'day', 'week', or 'month'.


$beginWeekOn

  • Access: public

Tells the calendar what day of the week to start the calendar
on. Value may be one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri',
and 'Sat'.


$firstDay

  • Access: public

Contains the date (Y-m-d format) of the first day to include
in the current calendar view.


$currentDay

  • Access: public

Contains the current date (Y-m-d format).


$lastDay

  • Access: public

Contains the date (Y-m-d format) of the last day to include
in the current calendar view.


$showFromHour = 0

  • Access: public

Tells Calendar to limit the hours displayed in 'day' view.
Must be an integer from 0 to 23.


$showToHour = 23

  • Access: public

Tells Calendar to limit the hours displayed in 'day' view.
Must be an integer from 0 to 23.


$activeCells = array ()

  • Access: public

Contains a list of the active cells in the Calendar
matrix. Active cells are the days that are in use.


$cellTemplate

  • Access: public

Contains a default template for use in each cell. The
cell template is not to be confused with the item template,
which displays an individual item on any given day.


$topBlock

  • Access: public

Reference to the cell that contains the space before
the first day of the month in the 'month' $showPeriod.


$bottomBlock

  • Access: public

Reference to the cell that contains the space after
the last day of the month in the 'month' $showPeriod.


$error

  • Access: public

If an error has occured within this class, you'll
find it in $error.


$originalData

  • Access: public

If this vCal object has been created from an existing data source,
this property contains the original data string.


$events = array ()

  • Access: public

List of events in this calendar. All events are vCalEvent objects.


$properties = array ()

  • Access: public

List of properties in this calendar. All properties are
vCalProperty objects.


$calendars = false

  • Access: public

List of calendars in this calendar container. All calendars are
vCal objects. A vCal object may act as either a calendar or as a container
of multiple calendars. This property is false if this is not a container.


$tag = 'VCALENDAR'

  • Access: public

This is the name of the surrounding BEGIN and END tag. It defaults
to 'VCALENDAR', but can be changed to support additional formats such as
'VCARD'.

Return to Top



Methods


vCal ($parseData = '')

  • Access: public

Constructor Method. Optionally parses an existing data
string into a complete vCal object.


parse ($data, $tag = 'VCALENDAR')

  • Access: public

Parses a vCalendar message into an array of calendar objects
with events and properties. Changing $tag to 'VCARD' allows vCal to
parse vCard files as well.


parseLine ($data)

  • Access: public
  • Return: vCalProperty object

Parses a property:value line into a vCalProperty object.


splitIntoKeys ($data)

  • Access: public
  • Return: aarray

Parses a string for a list of properties. Properties take the
format NAME:VALUE. Optional parameters may be added before the colon,
like this: NAME;PARAM1=VALUE1;PARAM2=VALUE2:VALUE, and the value itself
may also be broken into key/value pairs, like this:
NAME:FOO=BAR;FOO2=BAR2. Returns an array of names and vCalProperty
objects.


unfold ($data)

  • Access: public
  • Return: string

Unfolds a block of text by removing instances of a Carriage
Return (\r), a Line Feed (\n), and a single space.


fold ($data)

  • Access: public
  • Return: string

Folds a block of text by inserting a Carriage
Return (\r), a Line Feed (\n), and a single space every 70
characters.


quote ($data)

  • Access: public
  • Return: string

Checks whether a string contains a comma (,), a
semi-colon (;), or a colon (:), and adds double quotes
to the string if it does.


&addEvent ($type = 'VEVENT', $properties = array ())

  • Access: public
  • Return: object reference

Adds an event to the list. Returns a reference to the new
event object. The $type can be any valid vCalendar event type.


&addProperty ($name, $value, $parameters = array ())

  • Access: public
  • Return: object reference

Adds a property to the list. Returns a reference to the new
property object. The $name can be any valid vCalendar property.


write ()

  • Access: public
  • Return: string

Writes a vCalendar message out of the current object.

Return to Top

Copyright © 2008 Sitellite CMS Project

Powered by Sitellite 5.0 Content Management System