GearWheel php

This is a php class I whipped up for generating iCalendar (RFC 2445) files. It’s very simple and easy to use. My future plans on it are simply to support all of the protocol, as well as support creating xml/rss.. That will come in the second version, but for now, enjoy this simple, PHP 4-compatible class.

The name is a nerdy language pun, in typical me fashion. Gear is Old English for Year (and it’s pronounced year), but it looks like the modern English word gear. Both words make sense with wheel and this app is all about managing the turning of the year.. but not really. All open source programs, except good ones, slowly morph into programming languages. All this will ever do is generate ical and, in the future, RSS. So, it’s slightly ironic - comprehensive name for such an uncomplicated text file of a program.

License: BSD (but send improvements to me!)
Language/platform: PHP 4 and up

Download latest version

TODO:
-Make based on DOM so that the same class can create iCal or xml/rss output (just like Google does for its calendars)
-Add support for VTODO, VJOURNAL, and VFREEBUSY
-Add support for VTIMEZONE

To use, simply initialize an object with the name for your iCalendar. Then add events. You can retrieve the entire thing as a text file with getCal() and you can print it all out with printCal(). It uses unix timestamp for the time right now and I think it’s simple enough I’ll just keep it that way. You can certainly save to a file using this class, but probably the quickest way is to have your php output it and use headers to tell the browser it’s getting an iCalendar file: (technically, the file isn’t valid unless you have at least one event, but right now, the app is too brain-dead to care)

require_once("includes/ICalCreator.class.php");
$ical = new ICalCreator("My Awesome Calendar");
// feeding 0 to the first parameter brings us to 1969. Groovy!
$event = new ICalEvent(4294962435, 4294967295, "Ragnarok",
	"Loki Murders Baldr, Odin seeks revenge...", "Earth");
$ical->addEvent($event);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=band-collab.ics");
$ical->printCal();