[kronolith] vCalendar Into Kronolith

Brandon Knitter knitterb@blandsite.org
Fri, 10 May 2002 17:18:31 -0700


> > It looks like you already have written the Horde.data.Data class with the
> > type
> > IMPORT_ICALENDAR?  Is this work fairly close to done?  If so, is there
> > an
> > example of import that I can follow?
> 
> I haven't looked at the code for a while, but if I remember correctly, the 
> import routines already import the v/iCalendar files into a huge php array.
> 
> If so, all that's left to do is to map the array entries into an event 
> object and save it.

Okay, I started to look into this, about time huh? :)  I did notice a bug in the
horde/lib/Data.php version I'm using.  Not sure if you say this:

Around line 255 in the _build method:
                if ($data[$i]['name'] == 'BEGIN') {
                    $object['objects'][] = $this->build($data, $i);
                } else {
                    $object['params'][] = $data[$i];
                }

that first match needs to call "_build" not "build" (note the underscore).  I'm
assuming this is a recursively called routine.  When I try this out, it all
works quite well, except there is not data.

Question 1: Does PHP have a similar module to the Perl Data::Dumper routines?  I
want to dump what I get back from the Data_rfc2425::import method, cause it
seems to be an empty set to me?  Not sure if you've tested all this, but I just
can't seem to get any iCalendar objects to import properly, it flips through the
recurive calls, but it seems to lose the data.

I compared my example vCard to an iCalendar

== TEST vCard ===
BEGIN:VCARD
VERSION:2.1
N:Knitter;Brandon
FN:Brandon Knitter
ORG:Beyond.com;IS&T
TITLE:Member of Technical Staff
NOTE;ENCODING=QUOTED-PRINTABLE:This is a note.=0D=0A
TEL;WORK;VOICE:(408) 855-2676
TEL;HOME;VOICE:(510) 471-8835
TEL;VOICE:(408) 605-5616
TEL;PAGER;VOICE:Two Way, (888) 716-8152
TEL;WORK;FAX:(888) 716-8152
ADR;WORK:;Santa Clara;3200 Patrick Henry Drive;Santa Clara;CA;95054;USA
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Santa Clara=0D=0A3200 Patrick Henry
Drive=0D=0ASanta Clara, CA 95054=0D=0AUS=
A
KEY;X509;ENCODING=BASE64:
    MIICvzCCAiigAwIBAgIDBgzLMA0GCSqGSIb3DQEBAgUAMIGSMQswCQYDVQQGEwJaQTEVMBMG
    A1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xDzANBgNVBAoTBlRoYXd0
    ZTEdMBsGA1UECxMUQ2VydGlmaWNhdGUgU2VydmljZXMxKDAmBgNVBAMTH1BlcnNvbmFsIEZy
    ZWVtYWlsIFJTQSAyMDAwLjguMzAwHhcNMDExMTA4MDE0NjA1WhcNMDIxMTA4MDE0NjA1WjBs
    MR8wHQYDVQQDExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSIwIAYJKoZIhvcNAQkBFhNicmFu
    ZG9ua0BiZXlvbmQuY29tMSUwIwYJKoZIhvcNAQkBFhZrbml0dGVyYkBibGFuZHNpdGUub3Jn
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzJBMWLs4VNzgk8jnX1H7PcKGC7r3zsmkn
    /H61usoZiTg5GX/ujmtSBwZaicFnHA7hVpdSNfmUgjNJ5k6GvOUtzmekb9Z0D3RJexlT+wv1
    +vhX0Tudq2tUbI2SdmedaKeFUjwl1psNKLGoxnjzRKvJoFVSLOiiDx7V7FN6HEqIsQIDAQAB
    o0gwRjA2BgNVHREELzAtgRNicmFuZG9ua0BiZXlvbmQuY29tgRZrbml0dGVyYkBibGFuZHNp
    dGUub3JnMAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQECBQADgYEAD6cYQtDMwA1a2j/WTt4k
    mEcGDL52NKhp58e9KcA6xwmmuJM/M+fLn2rJjY0Q1IkcWMB7R6yQAuSwkSe4f8zz185pwu1W
    WllSAdZjAHFpTXRwE3EOJUyR2pVNqBqa4gNjGaQhJyeZSpk1cB9NGN1U98AybNnFBSVhPWpX
    W+1xbA8=


REV:20020418T042157Z
END:VCARD
== End TEST vCard ===

== TEST iCalendar ===
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
ATTENDEE;CN="Brandon
Knitter";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:brandonk@beyond.com
ATTENDEE;CN=knitterb@blandsite.org;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:knitterb@blandsite.org
ORGANIZER:MAILTO:brandonk@beyond.com
DTSTART:20020531T163000Z
DTEND:20020531T170000Z
TRANSP:OPAQUE
SEQUENCE:0
UID:040000008200E00074C5B7101A82E00800000000E0AD727D34F8C1010000000000000000100
 00000ED042A423864D6119C15000102C1F6AF
DTSTAMP:20020510T220806Z
SUMMARY:End of the month
PRIORITY:5
CLASS:PUBLIC
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
== End TEST iCalendar ===


Note that the iCalendar object has a recursive BEGIN block.  I can't seem to
figure out enough about PHP (yet!) to find where the data is going, but it sure
seems to go bye bye!  Any thoughts?  Have you successfully seen an iCalendar
object get imported?

Thanks in advance, at the very least I'm learning! :)

-bk