sfiCalCreatorPlugin - 0.0.2

Create iCal-xCal formatted calendar files.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

sfiCalCreatorPlugin

The sfiCalCreatorPlugin is a PHP implementation of RFC2445/RFC2446 to manage iCal/xCal formatted files.

alt text

It is an modified version from Kjell-Inge Gustafsson's iCalCreator 2.6 under LGPL License.

Installation

To install the plugin for a symfony project, the usual process is to use the symfony command line.

With Symfony > 1.0, use:

$ symfony plugin:install --stability=alpha sfiCalCreatorPlugin

Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's plugins/ directory.

Clear the cache to enable the autoloading to find the new classes:

$ php symfony cc

You're done.

Contents

The plugin contains seven classes, sfiCalCalendar, sfiCalCalendarComponent, sfiCalEvent, sfiCalFreeBusy, sfiCalTimezone, sfiCalTodo and sfiCalJornal. These classes offer the same functionality as the original classes. These are supplemented by methods which facilitate working with Symfony. The original names of the classes are vcalendar, calendarComponent, vevent, vfreebusy, vtimezone, vtodo and vjornal.

Note: You can use both, but the when using the original class name, the additional methods are not available.

Full documentation

After installation, you will find a detailed documentation in the directory /plugins/sfiCalPlugin/doc/using.html.

Usage

1. Simple Usage

The call in a normal action.class.php is as follows:

public function executeIndex(sfWebRequest $request) {
    $v = new sfiCalCalendar();                          // initiate new CALENDAR
    $e = new sfiCalEvent();                             // initiate a new EVENT
    $e->setProperty( 'categories', 'FAMILY' );                   // catagorize
    $e->setProperty( 'dtstart',  2006, 12, 24, 19, 30, 00 );  // 24 dec 2006 19.30
    $e->setProperty( 'duration', 0, 0, 3 );                    // 3 hours
    $e->setProperty( 'description', 'x-mas evening - diner' );    // describe the event
    $e->setProperty( 'location', 'Home' );                     // locate the event
    $v->addComponent( $e );                        // add component to calendar

    /* alt. production */
    // $v->returnCalendar();                       // generate and redirect output to user browser
    /* alt. dev. and test */
    $this->ical = $v->createCalendar();                   // generate and get output in string, for testing?
    return sfView::NONE;
}

2. Usage with database

The choice of ORM is not important. For this example I use Propel.

public function executeCalendar(sfWebRequest $request) {
    $v = new sfiCalCalendar();
    $v->setConfig( "unique_id", "domain.com" );
    $v->setProperty( "x-wr-calname", "Calendar Sample" );
    $v->setProperty( "X-WR-CALDESC", "Calendar Description" );
    $v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" );

    // Read data from database
    $c  = new Criteria();
    $c->addAscendingOrderByColumn(ConcertPeer::DATETIME);
    $c->add(ConcertPeer::DATETIME,mktime(0,0,0,date("n"),1,date("Y")),Criteria::GREATER_THAN);
    $concertList = ConcertPeer::doSelect($c);

    // iterate on the data to generate events
    foreach ($concertList as $concert) {
        $e = new sfiCalEvent();                           // initiate a new EVENT
        $e->setProperty( 'categories', 'MUSIC' );                   // catagorize
        $e->setProperty( 'dtstart' ,   date("Y",strtotime($concert->getDateTime())),date("m",strtotime($concert->getDateTime())),date("d",strtotime($concert->getDateTime())),date("H",strtotime($concert->getDateTime())),date("i",strtotime($concert->getDateTime())),00);  // 24 dec 2006 19.30
        $e->setProperty( 'duration' ,   0, 0, 2 );                    // 3 hours
        $e->setProperty( 'description',strip_tags( $concert->getMember()->getName().' ('.ucfirst($concert->getMember()->getTyp()).') - '.$concert->getDescription()));    // describe the event
        $e->setProperty( "summary", strip_tags($concert->getMember()->getName()));
        $e->setProperty( 'location', strip_tags($concert->getCity()));                     // locate the event
        if($concert->getUpdatedAt())
            $e->setProperty( 'last-modified' , date("Y",strtotime($concert->getUpdatedAt())),date("m",strtotime($concert->getUpdatedAt())),date("d",strtotime($concert->getUpdatedAt())),date("H",strtotime($concert->getUpdatedAt())),date("i",strtotime($concert->getUpdatedAt())),00);
        else
            $e->setProperty( 'last-modified' , date("Y",strtotime($concert->getCreatedAt())),date("m",strtotime($concert->getCreatedAt())),date("d",strtotime($concert->getCreatedAt())),date("H",strtotime($concert->getCreatedAt())),date("i",strtotime($concert->getCreatedAt())),00);
        $e->setProperty( "contact", strip_tags($concert->getMember()->getKontakt()) );
        $e->setProperty( "url", $concert->getUrl());
        //$e->setProperty( "geo", 11.23456, -23.45678 );
        $v->addComponent( $e );                        // add component to calendar
    }

    /* alt. production */
    $v->returnCalendar();                       // generate and redirect output to user browser
    /* alt. dev. and test */
    $this->ical = $v->createCalendar();         // generate and get output in string, for testing?
    return sfView::NONE;
}

Save the calendar

// Save the calendar
$Timelog->save('/path/to/Timelog/file.jpg', 'image/jpg');

Coming soon

The sfiCalCreatorPlugin you already offers a wonderful range of functions. There follows a list of things on which you can still rejoice:

  • Improve the date setter. (Sept. 2010)
  • Make it easier to save the calendars.
  • Include a cron job plugin to renew the stored calendar regularly.

Detailed Documentation

Based on iCalcreator class v2.6
copyright (c) 2007-2008 Kjell-Inge Gustafsson, kigkonsult
www.kigkonsult.se/iCalcreator
ical@kigkonsult.se

Description:

iCalcreator is a PHP implementation of RFC2445/RFC2446 to manage iCal/xCal formatted files.

1. INTRO

iCalcreator is a PHP class managing iCal formatted files for non-calendar systems like CMS, project management systems and other applications able to process calendar information like agendas, tasks, reports, totos, journaling data and for communication with calendar systems and applications.

iCalcreator features create, parse, edit and select calendar and calendar components.

iCalcreator is built of a single class file with a simple interface and are calendar component property oriented. Development environment is PHP version 5.x but coding is done to meet 4.x backward compability.

Ical

A short iCal description is found at Wikipedia. If You are not familiar with iCal, read this first!
Knowledge of calendar protocol rfc2445/rfc2446 is to recommend;
rfc2445 - Internet Calendaring and Scheduling Core Object Specification (iCalendar)
rfc2446 - iCalendar Transport-Independent Interoperability Protocol (iTIP) Scheduling Events, BusyTime, To-dos and Journal Entries.

Get RFC2445 - Internet Calendaring and Scheduling Core Object Specification (iCalendar) in text and HTML format, RFC2446 - iCalendar Transport-Independent Interoperability Protocol (iTIP) Scheduling Events, BusyTime, To-dos and Journal Entries in text format.

All iCalcreator functions calls are made as simple as possible BUT (, !!!,) read these rfc's properly! xCal (iCal xml) output format is supported but still experimental.


[index][top]

In this manual

This style is used for text.

This style is used for formats.

This style is used for PHP coding examples. // this style is used for coding comments.

This style is used for content details.

This style is used for RFC2445 quotes.

Compatibility

The following properties may be required when importing iCal files into some calendaring software (MS etc.):
on calendar level
METHOD property (value PUBLISH etc.)
X-WR-CALNAME x-property
X-WR-CALDESC x-property
X-WR-TIMEZONE x-property
on component level
DTSTAMP property (auto created)
UID property (auto created)
Recommendation is also to set unique_id just after creating a new sfiCalCalendar object, to ensure accurate setting of all components UID property, even before parse.

Example

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setProperty( "x-wr-calname", "Calendar Sample" ); $sfiCalCalendar->setProperty( "X-WR-CALDESC", "Calendar Description" ); $sfiCalCalendar->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); .. .

Addendum

Download iCalcreator coding samples.
Examples how to employ iCalcreator in software development:
The iCal file event editor and tinycal, calendar-in-a-box.

There are free iCal/xCal icons in the images directory, to use as buttons on a webpage.

The command coding examples are only examples, recommendation is to use a coding standard, the following, incomplete, list is a good start; http://www.dagbladet.no/development/phpcodingstandard/http://ez.no/ezpublish/documentation/development/standards/phphttp://framework.zend.com/manual/en/coding-standard.htmlhttp://gforge.org/docman/view.php/1/2/coding-standards.htmlhttp://pear.php.net/manual/en/standards.php
[index][top]

1.1 INDEX

1. INTRO
1.1 INDEX
1.2 INSTALL

2. Calendar Component list
2.1 sfiCalCalendar
2.2 sfiCalEvent
2.3 sfiCalTodo
2.4 sfiCalJournal
2.5 sfiCalFreebusy
2.6 sfiCalAlarm
2.7 sfiCalTimezone
2.8 Component Properties

3. Function list
3.1 Calendar object functions
3.1.1 Calendar object constructors
3.1.1.1 sfiCalEvent
3.1.1.2 sfiCalTodo
3.1.1.3 sfiCalJournal
3.1.1.4 sfiCalFreebusy
3.1.1.5 sfiCalAlarm
3.1.1.6 sfiCalTimezone

3.1.2 Calendar property functions
3.1.2.1 deleteProperty
3.1.2.2 getProperty
3.1.2.3 setProperty
3.1.2.4 CALSCALE
3.1.2.5 METHOD
3.1.2.6 VERSION
3.1.2.7 X-PROPERTY

3.1.3 Calendar component functions
3.1.3.1 deleteComponent
3.1.3.2 getComponent
3.1.3.3 selectComponents
3.1.3.4 setComponent

3.1.4 Calendar input/output functions
3.1.4.1 parse and merge
3.1.4.2 createCalendar
3.1.4.3 returnCalendar
3.1.4.4 saveCalendar
3.1.4.5 sort
3.1.4.6 useCachedCalendar

3.1.5 Calendar configuration functions
3.1.5.1 Allow empty components
3.1.5.2 Component information
3.1.5.3 Delimiter
3.1.5.4 Directory
3.1.5.5 Fileinfo
3.1.5.6 Filename
3.1.5.7 Filesize
3.1.5.8 Format
3.1.5.9 Language
3.1.5.10 NewlineChar
3.1.5.11 Unique_id
3.1.5.12 URL

3.2 Calendar component/object property function list
3.2.1 deleteProperty
3.2.2 getProperty
3.2.3 parse
3.2.4 setProperty
3.2.5 ACTION
3.2.6 ATTACH
3.2.7 ATTENDEE
3.2.8 CATEGORIES
3.2.9 CLASS
3.2.10 COMMENT
3.2.11 COMPLETED
3.2.12 CONTACT
3.2.13 CREATED
3.2.14 DESCRIPTION
3.2.15 DTEND
3.2.16 DTSTAMP
3.2.17 DTSTART
3.2.18 DUE
3.2.19 DURATION
3.2.20 EXDATE
3.2.21 EXRULE
3.2.22 FREEBUSY
3.2.23 GEO
3.2.24 LAST-MODIFIED
3.2.25 LOCATION
3.2.26 ORGANIZER
3.2.27 PERCENT-COMPLETE
3.2.28 PRIORITY
3.2.29 RDATE
3.2.30 RECURRENCE-ID
3.2.31 RELATED-TO
3.2.32 REPEAT
3.2.33 REQUEST-STATUS
3.2.34 RESOURCES
3.2.35 RRULE
3.2.36 SEQUENCE
3.2.37 STATUS
3.2.38 SUMMARY
3.2.39 TRANSP
3.2.40 TRIGGER
3.2.41 TZID
3.2.42 TZNAME
3.2.43 TZOFFSETFROM
3.2.44 TZOFFSETTO
3.2.45 TZURL
3.2.46 UID
3.2.47 URL
3.2.48 X-PROPERTY

3.3 Calendar Component configuration functions
3.3.1 Language

3.4 Calendar component object misc. functions
3.4.1 deleteComponent
3.4.2 getComponent
3.4.3 setComponent

4. COPYRIGHT AND LICENSE

[index][top]

1.2 INSTALL

Unpack to any folder
- add this folder to your include-path
- or unpack to your application-(include)-folder
Add

require_once [folder/]iCalcreator.class.php;

to your php-script.

If using php version 5.x, the default timezone need to be set/altered, now "Europe/Stockholm", line 47 in the class file.

When creating a new calendar object, review config settings.
[index][top]

2. Calendar Component list

Quote from rfc2445! (Described in iCal output format, content corresponds to xCal format.)

2.1 sfiCalCalendar

icalobject = 1*("BEGIN" ":" "sfiCalCalendar" CRLF

icalbody

"END" ":" "sfiCalCalendar" CRLF)


icalbody = calprops component
calprops = 2*(

"prodid" and "version" are both REQUIRED, but MUST NOT occur more than once

prodid / version /

"calscale"and "method"are optional, but MUST NOT occur more than once

calscale / method /

x-prop

)

component = 1*(eventc / todoc / journalc / freebusyc / timezonec / iana-comp* / x-comp*)

iana-comp = "BEGIN" ":" iana-token CRLF

1*contentline

"END" ":" iana-token CRLF

x-comp = "BEGIN" ":" x-name CRLF

1*contentline

"END" ":" x-name CRLF

*) not supported by iCalcreator


[index][top][up]

2.2 sfiCalEvent

"BEGIN" ":" "sfiCalEvent" CRLF

eventprop *alarmc

"END" ":" "sfiCalEvent" CRLF

eventprop = *(

the following are optional,but MUST NOT occur more than once

class / created / description / dtstart /

geo / last-mod / location / organizer / priority /

dtstamp / seq / status / summary /

transp / uid / url / recurid /

either "dtend" or "duration" may appear in a "eventprop",

but "dtend" and "duration" MUST NOT occur in the same "eventprop"

dtend / duration /

the following are optional, and MAY occur more than once

attach / attendee / categories / comment /

contact / exdate / exrule / rstatus /

related / resources / rdate / rrule / x-prop

)
[index][top][up]

2.3 sfiCalTodo

"BEGIN" ":" "sfiCalTodo" CRLF

todoprop *alarmc

"END" ":" "sfiCalTodo" CRLF

todoprop = *(

the following are optional, but MUST NOT occur more than once

class / completed / created / description / dtstamp / dtstart /

geo / last-mod / location / organizer / percent / priority /

recurid / seq / status / summary /uid / url /

either "due" or "duration" may appear in a "todoprop",

but "due" and "duration" MUST NOT occur in the same "todoprop"

due / duration /

the following are optional,and MAY occur more than once

attach / attendee / categories / comment /

contact / exdate / exrule / rstatus /

related / resources / rdate / rrule / x-prop

)
[index][top][up]

2.4 sfiCalJournal

journalc = "BEGIN" ":" "sfiCalJournal" CRLF

jourprop

"END" ":" "sfiCalJournal" CRLF

jourprop = *(

the following are optional, but MUST NOT occur more than once

class / created / description / dtstart /

dtstamp / last-mod / organizer / recurid /

seq / status / summary /uid / url /

the following are optional,and MAY occur more than once

attach / attendee / categories / comment /

contact / exdate / exrule / related /

rdate / rrule / rstatus / x-prop

)
[index][top][up]

2.5 sfiCalFreebusy

"BEGIN" ":" "sfiCalFreebusy" CRLF

fbprop

"END" ":" "sfiCalFreebusy" CRLF

fbprop = *(

the following are optional, but MUST NOT occur more than once

contact / dtstart / dtend / duration /

dtstamp / organizer / uid / url /

the following are optional,and MAY occur more than once

attendee / comment / freebusy / rstatus / x-prop

)
[index][top][up]

2.6 sfiCalAlarm

"BEGIN" ":" "sfiCalAlarm" CRLF

(audioprop / dispprop / emailprop / procprop)

"END" ":" "sfiCalAlarm" CRLF

audioprop = 2*(

"action" and "trigger" are both REQUIRED, but MUST NOT occur more than once

action / trigger /

"duration" and "repeat" are both optional,and MUST NOT occur more than once each,

but if one occurs, so MUST the other

duration / repeat /

the following is optional, but MUST NOT occur more than once

attach /

the following is optional, and MAY occur more than once

x-prop

)
dispprop = 3*(

the following are all REQUIRED, but MUST NOT occur more than once

action / description / trigger /

"duration" and "repeat" are both optional,and MUST NOT occur more than once each,

but if one occurs, so MUST the other

duration / repeat /

the following is optional, and MAY occur more than once

x-prop

)
emailprop = 5*(

the following are all REQUIRED, but MUST NOT occur more than once

action / description / trigger / summary

the following is REQUIRED, and MAY occur more than once

attendee /

"duration" and "repeat" are both optional, and MUST NOT occur more than once each,

but if one occurs, so MUST the other

duration / repeat /

the following are optional, and MAY occur more than once

attach / x-prop

)
procprop = 3*(

the following are all REQUIRED, but MUST NOT occur more than once

action / attach / trigger /

"duration" and "repeat" are both optional, and MUST NOT occur more than once each,

but if one occurs, so MUST the other

duration / repeat /

"description" is optional, and MUST NOT occur more than once

description /

the following is optional, and MAY occur more than once

x-prop

)
[index][top][up]

2.7 sfiCalTimezone

"BEGIN" ":" "sfiCalTimezone" CRLF

2*(

"tzid" is required, but MUST NOT occur more than once

tzid /

"last-mod" and "tzurl" are optional, but MUST NOT occur more than once

last-mod / tzurl /

one of "standardc" or "daylightc" MUST occur and each MAY occur more than once.

standardc / daylightc /

the following is optional, and MAY occur more than once

x-prop

)

"END" ":" "sfiCalTimezone" CRLF

standardc = "BEGIN" ":" "STANDARD" CRLF

tzprop

"END" ":" "STANDARD" CRLF

daylightc = "BEGIN" ":" "DAYLIGHT" CRLF

tzprop

"END" ":" "DAYLIGHT" CRLF


tzprop = 3*(

the following are each REQUIRED, but MUST NOT occur more than once

dtstart / tzoffsetto / tzoffsetfrom /

the following are optional, and MAY occur more than once

comment /rdate / rrule / tzname / x-prop

)
[index][top][up]

2.8 Component Properties

A comprehensive table showing relation between calendar components and properties. sfiCalTimezone properties are not included.

vtimezone properties are not included.

0-1 OPTIONAL property, MUST NOT occur more than once.
0-m OPTIONAL property, MAY occur more than once.
0 or 1=1 A pair of OPTIONAL properties, MUST NOT occur more than once each.
If one occurs, so MUST the other
0*1 A pair of OPTIONAL properties, MUST NOT occur more than once each.
If one occurs, so MUST NOT the other
1-m REQUIRED property, MAY occur more than once.
1 REQUIRED property, MUST NOT occur more than once.
 
  vevent vtodo vjournal vfreebusy valarm      
          audio display email procedure
action         1 1 1 1
attach 0-m 0-m 0-m 0-1   0-m 1
attendee 0-m 0-m 0-m 0-m     1-m  
categories 0-m 0-m 0-m          
class 0-1 0-1 0-1          
comment 0-m 0-m 0-m 0-m        
compleated   0-1            
contact 0-m 0-m 0-m 0-1        
created 0-1 0-1 0-1          
description 0-1 0-1 0-m     1 1 0-1
dtend 0*1     0-1        
dtstamp 0-1 0-1 0-1 0-1        
dtstart 0-1 0-1 0-1 0-1        
due   0*1            
duration 0*1 0*1   0-1 0 or 1=1 0 or 1=1 0 or 1=1 0 or 1=1
exdate 0-m 0-m 0-m          
exrule 0-m 0-m 0-m          
freebusy       0-m        
geo 0-1 0-1            
last-mod 0-1 0-1 0-1        
location 0-1 0-1            
organizer 0-1 0-1 0-1 0-1        
percent   0-1            
priority 0-1 0-1            
rdate 0-m 0-m 0-m          
recurid 0-1 0-1 0-1          
related 0-m 0-m 0-m          
repeat         0 or 1=1 0 or 1=1 0 or 1=1 0 or 1=1
resources 0-m 0-m            
rrule 0-m 0-m 0-m          
rstatus 0-m 0-m 0-m 0-m        
sequence 0-1 0-1 0-1          
status 0-1 0-1 0-1          
summary 0-1 0-1 0-1       1  
transp 0-1              
trigger         1 1 1 1
uid 0-1 0-1 0-1 0-1        
url 0-1 0-1 0-1 0-1        
x-prop 0-m 0-m 0-m 0-m 0-m 0-m 0-m 0-m

If not set, DTSTART and UID are created automatic by iCalcreator for sfiCalEvent, sfiCalTodo, sfiCalJournal and vfeebusy components when using calendar functions saveCalendar or returnCalendar or when fetching DTSTART/UID property value with component function getProperty.


[index][top][up]

3. Function list

3.1 Calendar object functions

3.1.1 Calendar object constructors

Initiate new CALENDAR.

Format

sfiCalCalendar()

Example

$calendar = new sfiCalCalendar();// initiate new CALENDAR


[index][top][up]

3.1.1.1 sfiCalEvent

Initiate calendar component EVENT.

Format

sfiCalEvent()

Example

$sfiCalEvent = new sfiCalEvent(); // initiate EVENT


[index][top][up]

3.1.1.2 sfiCalTodo

Initiate calendar component TODO.

Format

sfiCalTodo()

Example

$sfiCalTodo = new sfiCalTodo(); // initiate TODO


[index][top][up]

3.1.1.3 sfiCalJournal

Initiate calendar component JOURNAL.

Format

sfiCalJournal()

Example

$sfiCalJournal = new sfiCalJournal(); // initiate JOURNAL


[index][top][up]

3.1.1.4 sfiCalFreebusy

Initiate calendar component FREEBUSY.

Format

sfiCalFreebusy()

Example

$sfiCalFreebusy = new sfiCalFreebusy(); // initiate FREEBUSY


[index][top][up]

3.1.1.5 sfiCalAlarm

Initiate calendar component ALARM.

Format

sfiCalAlarm()

Example

$sfiCalAlarm = new sfiCalAlarm(); // initiate ALARM


[index][top][up]

3.1.1.6 sfiCalTimezone

Initiate calendar component TIMEZONE.

Format

sfiCalTimezone()

Example

$sfiCalTimezone = new sfiCalTimezone(); // initiate TIMEZONE


[index][top][up]

3.1.2 Calendar property functions

3.1.2.1 deleteProperty

General calendar deleteProperty function, simplifying removal of calendar properties.
FALSE is returned if no property exists or when end-of-properties at consecutive function calls.

Format

deleteProperty( [ string PropName [, int order=1 ] )

Propname - case independent, strict rfc2445 component property names, unknown/missing Propname will be regarded as X-property. order - if missing 1st/next occurence, used with multiply (property) occurences

Example 1

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); if( !$sfiCalCalendar->deleteProperty( "method" ))   echo "METHOD property not found"; .. .


[index][top][up]

3.1.2.2 getProperty

General calendar getProperty function, simplifying fetch of calendar properties.
FALSE is returned if no property exists or when end-of-properties at consecutive function calls.

Format

getProperty( [ string PropName [, int order=1 [, bool complete=FALSE ]]] )

Propname - case independent, strict rfc2445 component property names, unknown/missing Propname will be regarded as X-property. order - if missing 1st/next occurence, used with multiply (property) occurences complete - FALSE (default) : output only property value - TRUE : output = array("value"=> <value> ,"params" => <parameter array>)

Example 1

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); $calscale = $sfiCalCalendar->getProperty( "calscale" ); .. .

Example 2

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); while( $xprop = $sfiCalCalendar->getProperty( )) { // get x-properties in order.. . .. .


[index][top][up]

3.1.2.3 setProperty

General calendar setProperty function,simplifying insert of calendar properties.
A successful update returns TRUE.

Format

setProperty( string PropName, mixed Proparg_1 *[, mixed Proparg_n] )

Propname case independent, strict rfc2445 calendar property names, unknown Propname will be regarded as X-property.

Example

$sfiCalCalendar = new sfiCalCalendar(); // initiate new CALENDAR $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setProperty( "calscale", "GREGORIAN" );


[index][top][up]

3.1.2.4 CALSCALE

This property defines the calendar scale used for the calendar information specified in the iCalendar object.

The default value is "GREGORIAN", implied when missing.
Delete CALSCALE
Remove CALSCALE from component.
Get Calscale
Fetch property value.

Format

getProperty( "calscale" )

Example

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); $calscale = $sfiCalCalendar->getProperty( "calscale" ); .. .

Set CALSCALE
Insert property value.

Format

setProperty( "calscale", string value )

Example

$sfiCalCalendar = new sfiCalCalendar(); // initiate new CALENDAR $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setProperty( "calscale", "GREGORIAN" ); .. .


[index][top][up]

3.1.2.5 METHOD

This property defines the iCalendar object method associated with the calendar object.

METHOD property (value PUBLISH etc.) may be required when importing iCal files into some calendaring software (MS etc.), as well as x-properties "X-WR-CALNAME", "X-WR-CALDESC" and "X-WR-TIMEZONE" and (auto created) DTSTAMP and UID properties.
Delete METHOD
Remove METHOD from component.
Get METHOD
Fetch property value.

Format

getProperty( "method" );

Example

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); $method = $sfiCalCalendar->getProperty( "method" ) .. .

Set METHOD
Insert property value.

Format

setProperty( "method", string value )

Example

$sfiCalCalendar = new sfiCalCalendar(); // initiate new CALENDAR $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setProperty( "method", "PUBLISH" )


[index][top][up]

3.1.2.6 VERSION

This property specifies the identifier corresponding to the highest version number or the minimum and maximum range of the iCalendar specification that is required in order to interpret the iCalendar object.
Get Version
Fetch property value.

Format

getProperty( "version" )

Example

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); $version = $sfiCalCalendar->getProperty( "version" ) .. .

Set Version
Insert property value. Only version 2.0 valid, version is AUTO generated at calendar creation.

Format

setProperty( "version", string version )

Example

$sfiCalCalendar = new sfiCalCalendar(); // initiate new CALENDAR $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setProperty( "version", "2.0" )


[index][top][up]

3.1.2.7 X-PROPERTY

A calendar property with TEXT value and a name with an "X-" prefix. In a calendar, an x-prop, with an unique name, can occur only once but the number of x-props are unlimited.

X-properties "X-WR-CALNAME", "X-WR-CALDESC" and "X-WR-TIMEZONE" may be required when importing iCal files into some calendaring software (MS etc.), as well as METHOD property (value PUBLISH etc.) and (auto created) DTSTAMP and UID properties.
Delete X-PROPERTY
Remove X-PROPERTY from calendar.

Format

deleteProperty( "<X-PROPERTY>" )

Example 1

$sfiCalCalendar->deleteProperty( "<X-PROPERTY>" );

Example 2

Deleting all x-properties.

while( $sfiCalCalendar->deleteProperty()) continue;

Get X-PROPERTY
Fetch property value.

Format

getProperty()
getProperty( "<X-PROPERTY>" )

output = array( propertyName1, propertyData2 )

getProperty( FALSE, propOrderNo/FALSE, TRUE )

output = array( propertyName1 , array( "value" => propertyData2 ) , "params" => params 3))

Example 1

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); while( $xprop = $sfiCalCalendar->getProperty( )) { //read all x-props in a loop .. .

$xprop = array( propertyName1, propertyData2 )

Example 2

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); if( $xprop = $sfiCalCalendar->getProperty( "X-WR-TIMEZONE" )) { //if exists, read X-WR-TIMEZONE x-prop .. .

$xprop = array( "X-WR-TIMEZONE", propertyData2 )

Example 3

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); while( $xprop = $sfiCalCalendar->getProperty( FALSE, FALSE, TRUE )) { .. .

$xprop = array( propertyName1 , array( "value " => propertyData2 ) , "params "=> params 3 )

Set X-PROPERTY
Insert property name and value. If an x-prop with the same name already exists, it will be replaced. PropertyName are always stored upperCase, ex. x-wr-calname => X-WR-CALNAME.

Format

setProperty( propertyName, propertyData [, params ] )

propertyName1 = Any property name with a "X-" prefix propertyData2 = Value type TEXT params3 = array( ["LANGUAGE" => "<lang>"] [, xparam] ) xparam = *[ xparamkey => xparamvalue ] propOrderNo = int ordernumber, 1=1st, 2=2nd etc

Example

$sfiCalCalendar = new sfiCalCalendar(); // initiate new CALENDAR $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); // set some X-properties.. . $sfiCalCalendar->setProperty( "x-wr-calname", "Calendar Sample" ) $sfiCalCalendar->setProperty( "X-WR-CALDESC", "Calendar Description" ); $sfiCalCalendar->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" );


[index][top][up]

3.1.3 Calendar component functions

3.1.3.1 deleteComponent

Remove component from calendar.
FALSE is returned if no property exists or when end-of-properties at consecutive function calls.

format 1

Remove component with order number (1st=1, 2nd=2.. .).

deleteComponent( int orderNumber )

format 2

Remove component with component type (e.g. "sfiCalEvent") and order 1 alt. suborder number.

deleteComponent( string componentType [, int componentSuborderNumber])

format 3

Remove component with UID. N.B UID is NOT set for ALARM / TIMEZONE components.

deleteComponent( string UID )

Example 1

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); $sfiCalCalendar->deleteComponent( 1 ); $sfiCalCalendar->deleteComponent( "sfiCalTodo", 2 ); $sfiCalCalendar->deleteComponent( "20070803T194810CEST-0123U3PXiX@domain.com"); .. .

Example 2

Deleting all components, using format 2 without order number.

$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( "filename", "file.ics" ); $sfiCalCalendar->parse(); .. . while( $sfiCalCalendar->deleteComponent( "sfiCalEvent")) continue; .. . $sfiCalTodo = $sfiCalCalendar->getComponent( 'sfiCalTodo' ); while( $sfiCalTodo->deleteComponent( "sfiCalAlarm")) continue; .. .


[index][top][up]

3.1.3.2 getComponent

Get component from calendar.
FALSE is returned if no property exists or when end-of-properties at consecutive function calls.

format 1

Get next component, until end-of-components.

getComponent()

format 2

Get component with order number (1st=1, 2nd=2.. .).

getComponent( int orderNumber )

format 3

Get (next) component with component type (until end-of-components) alt. get component with component type and suborder number (1st=1, 2nd=2.. .).

getComponent( string componentType [, int componentSuborderNumber])

format 4

Get component with UID as key. N.B UID is NOT set for ALARM / TIMEZONE components.

getComponent( string UID )

Example 1

<

p class="example">$sfiCalCalendar = new sfiCalCalendar(); $sfiCalCalendar->setConfig( "unique_id", "domain.com" ); $sfiCalCalendar->setConfig( &quo