iCalendar library (critique new use cases for qCal library)

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

iCalendar library (critique new use cases for qCal library)

Post 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/
Last edited by Luke on Tue Sep 25, 2007 7:12 pm, edited 3 times in total.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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');
?>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

That's a lot of code for General Discussion Ninja. :wink:
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

good point... but in my defense, the original question was "What should I call this" :oops:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Maybe you could ask a moderator to move it to PHP - Theory & Design perhaps? ;)
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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!).
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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');
(#10850)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Are you contagious yet? ;)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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_*.
(#10850)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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) ?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

In that case pical or phical are good ... or how about phpical or icalphp ;)
(#10850)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
Post Reply