Page 1 of 3

iCalendar library (critique new use cases for qCal library)

Posted: Wed Mar 28, 2007 4:51 pm
by Luke
I've decided to try putting together an open-source php5 library that would allow users to parse and create iCalendar files on the fly. It may not ever see the light of day, but I think it will be a great learning experience. I would just like to get some suggestions as to what to name this library. I was going to go with PHPiCal, but that is kind of already taken... ( http://phpical.org/ )

As far as I know, nothing like this exists. At least not an open-source library... I take that back. I just looked on sourceforge and found bennu. I'll look at it and make an assessment on whether it's good or not. :)

UPDATE- 9/25/07 - I have added a google code homepage for this project here: http://code.google.com/p/qcal/

Posted: Wed Mar 28, 2007 5:08 pm
by Maugrim_The_Reaper
If you go ahead, be sure to keep the parser well separated. For example, the iCalendar specification (well, RFC at least) is also followed by the hCal microformat so the two can be made interchangeable. I've been fiddling with a hCal parser in bits and pieces so iCal should be a very tidy format to work on.

Posted: Wed Mar 28, 2007 5:19 pm
by Luke
Here is something I just whipped out just to get an idea of how I want the interface to be... let me know if it's WAY off. Keep in mind it's just a rough idea of how I want it to work and I haven't finished reading the RFC yet. Also, I'm using TDD so the interface will change a lot.

Code: Select all

<?php
// some use cases for PHPiCal

$iCal = new PHPiCal('Luke\'s Test Calendar', 'publish');

$event = new PHPiCal_Event; // uid auto-generated
//$event = new PHPiCal_Event($unique_id); // uid set by user
$event->setTitle('Luke\'s Birthday');
$event->setStartDate(new PHPiCal_Date('2007-04-23'));
$event->setStartTime(new PHPiCal_Time('4:00pm'));
$event->setDescription('Just a nice little birthday get together');
/** and so on **/
$iCal->attach($event);

$todo = new PHPiCal_Todo;
$todo->setTitle('Luke\'s friend\'s birthday');
$todo->setStartDate(new PHPiCal_Date('2007-04-07'));
$todo->setStartTime(new PHPiCal_Time('5:00am'));
/** and so on **/
$iCal->attach($todo);

echo $iCal->render(new PHPiCal_Renderer_Month);

// reading a calendar

$iCal2 = new PHPiCal;

$iCal2->import('./files/test_calendar.ics');
echo $iCal2->render(new PHPiCal_Renderer_hCal);

// exporting to a file

$iCal3 = new PHPiCal('Luke\'s Test Calendar', 'publish');

// add some events, todos, journal entries, etc.

$iCal3->exportFile('./files/test_calendar.ics');
?>

Posted: Wed Mar 28, 2007 5:21 pm
by RobertGonzalez
That's a lot of code for General Discussion Ninja. :wink:

Posted: Wed Mar 28, 2007 5:38 pm
by Luke
good point... but in my defense, the original question was "What should I call this" :oops:

Posted: Wed Mar 28, 2007 5:52 pm
by RobertGonzalez
Maybe you could ask a moderator to move it to PHP - Theory & Design perhaps? ;)

Posted: Thu Mar 29, 2007 3:19 am
by Maugrim_The_Reaper
Looks fine ;). The Data and Time fields could have an integrated alias, e.g. setDateTime() so it can accept a timestamp or date string. Also be sure to account for the whether the date is local or UTC (or whether it needs conversion even). Only other tricky thing to watch is the format's line endings - CRLF per the RFC (ugh!).

Posted: Thu Mar 29, 2007 1:06 pm
by Christopher
I am wondering whether the render() and import()/export() methods should be in the main class or moved out to other classes that take a core object in the constructor. I think moving them out would make the system more modular and customizable.

So:

Code: Select all

$month = new PHPiCal_Renderer_Month($iCal);
echo $month ->render();

// reading a calendar

$iCal2 = new PHPiCal;

$io = new PHPiCal_IO($iCal);
$io>import('./files/test_calendar.ics');

$hCal = new PHPiCal_Renderer_hCal($iCal2);
echo $hCal->render();

// exporting to a file

$iCal3 = new PHPiCal('Luke\'s Test Calendar', 'publish');

// add some events, todos, journal entries, etc.

$io->setCal($iCal3);
$io->exportFile('./files/test_calendar.ics');

Posted: Thu Mar 29, 2007 1:22 pm
by Luke
probably will... that is where tdd will come it. It will help me decide on a lot of these ui details. the great thing is... I think I am FINALLY starting to get the hang of this whole testing thing.

Posted: Thu Mar 29, 2007 4:04 pm
by Maugrim_The_Reaper
Are you contagious yet? ;)

Posted: Fri Mar 30, 2007 12:43 am
by Luke
:: coughs :: maybe :wink:

Alright, so nobody has any ideas for what to call this thing. I'm at a loss myself. maybe iCalPHP?

Posted: Fri Mar 30, 2007 1:02 am
by Christopher
I think PHPiCal or iCalPHP are silly because you don't really need to say it's PHP. I would just call the classes Icalendar_* or Ical_*.

Posted: Fri Mar 30, 2007 1:12 am
by Luke
Well the issue with that is iCal is already a known piece of software and iCalendar is a known standard. Let's say somebody on this forum asks "does anybody know where I can find an oop php library that is capable of creating/parsing iCalendar files?". I'd like for the answer to be yea, go do http://www.icalphp.com and download iCalPHP. If I were to name the library simply iCal, that would not be possible.

I really don't like the name iCalPHP nor PHPiCal though. What do you think?

EDIT: What do you think of pical (PHPiCalendar) ?

Posted: Fri Mar 30, 2007 2:04 am
by Christopher
In that case pical or phical are good ... or how about phpical or icalphp ;)

Posted: Fri Mar 30, 2007 2:21 am
by Kieran Huggins
Php Extension for Normalized iCal Syntax

I happen to know of a computer store with the ideal logo!

Seriously though, maybe you should stick with the incredibly un-sexy "PHPiCal" name, it's far more Google friendly.