rsscalCreator

Description:

rsscalCreator is a PHP class that implements the rsscal (RDF) and RSS (2.0) specification of iCal, RFC2445. Only the calendar event component is implemented.

Index

1. INTRO
2. METHODS
2.1 INITIATION METHODS
2.2 CHANNEL MANAGEMENT METHODS
2.3 ITEM MANAGEMENT METHODS
2.4 IMAGE MANAGEMENT METHODS
2.5 TEXTINPUT MANAGEMENT METHODS
2.6 FEED MANAGEMENT METHODS
2.7 FILE MANAGEMENT METHODS
3. COPYRIGHT AND LICENSE

1. INTRO

Knowledge of calendar and rfc2445 - Internet Calendaring and Scheduling Core Object Specification (iCalendar) - is necessary!

RFC2445 in text format: www.kigkonsult.se/iCalcreator/iCalDictionary/rfc2445.txt.
RFC2445 in HTML format: www.kigkonsult.se/iCalcreator/iCalDictionary/index.html.

For information about RSS, see RSS tutorial.
For information about RDF specification, see http://web.resource.org/rss/1.0/spec.

For information about RSS 2.0, see RSS 2.0 Specification.

The RDF model describe four elements with subelements;
elementsubelements1.02.0
channelrequiredtitlerequiredrequired
linkrequiredrequired
descriptionrequiredrequired
languagen/aoptional
copyrightn/aoptional
managingEditorn/aoptional
webMastern/aoptional
pubDaten/aoptional
lastBuildDaten/aoptional
categoryn/aoptional
generatorn/aoptional
docsn/aoptional
cloudn/aoptional
 req. attribute "domain"
 req. attribute "port"
 req. attribute "path"
 req. attribute "registerProcedure"
 req. attribute "protocol"
ttln/aoptional
ratingn/aoptional
skipHoursn/aoptional
skipDaysn/aoptional
 
imageoptionaltitlerequiredrequired
urlrequiredrequired
linkrequiredrequired
widthn/aoptional
heightn/aoptional
 
itemone or more
ocurrences
titlerequiredtitle or description required
linkrequiredoptional
descriptionoptionaltitle or description required
authorn/aoptional
categoryn/aoptional
 opt. attribute "domain" value=true/false
commentsn/aoptional
enclosuren/aoptional
 req. attribute "url"
 req. attribute "length"
 req. attribute "type"
guidn/aoptional
 opt. attribute "isPermaLink" value : true (default) / false
pubDaten/aoptional
sourcen/aoptional
 req. attribute "url"
 
textinputoptionaltitlerequiredrequired
descriptionrequiredrequired
namerequiredrequired
linkrequiredrequired

The 'Dublin Core' Namespace Declaration (explanation at http://dublincore.org/documents/dces/ allows subelements (all optional);

elementsubelements1.02.0
channel / *item / image? / textinput?dc:titleoptionaloptional
dc:creatoroptionaloptional
dc:subjectoptionaloptional
dc:descriptionoptionaloptional
dc:publisheroptionaloptional
dc:contributoroptionaloptional
dc:dateoptionaloptional
dc:typeoptionaloptional
dc:formatoptionaloptional
dc:identifieroptionaloptional
dc:sourceoptionaloptional
dc:languageoptionaloptional
dc:relationoptionaloptional
dc:coverageoptionaloptional
dc:rightsoptionaloptional

The EVENT Namespace Declaration describes event (optional) subelements for ITEM elements:

elementsubelements1.02.0
*itemev:startdateoptionaloptional
ev:enddateoptionaloptional
ev:locationoptionaloptional
ev:organizeroptionaloptional
ev:typeoptionaloptional
[index]

2. Usage

A simple demo of using rsscalCreator:

<?php

/* ensure the right path to class file */
require_once './rsscalCreator.class.php';

/* set all required elements (title, link, description) */
$feed = new rsscalCreator( $title, $link, $desc );

/* use a while/for/foreach-loop to set the items */
foreach( $databaseQueryResult as $data ) {
  /* set items subelements, title (required), link (required), description (optional) */
  $item = new rsscalItem( $data['title'], $data['link'], $data['desc'] );
  /* add optional item subelement, one by one (element name, element content) to item */
  $item->addElement( 'ev:type', $data['type]' );
  $item->addElement( 'ev:organizer', $data['organizer'] );
  $item->addElement( 'ev:location', $data['location'] );
  $item->addElement( 'ev:startdate', $data['startdate'] );
  $item->addElement( 'ev:enddate', $data['enddate'] );
  $item->addElement( 'dc:subject', $data['subject'] );
  /* add item to feed */
  $feed->addItem( $item );
}

/* create and redirect RSS feed to browser */
$feed->returnRSS();

?>

Se more more samples at the samples*.php files.

Don't forget to test the feed at feedvalidator.org

Please use icons and script in images directory!

[index]

2. METHODS

2.1 INITIATION METHODS

rsscalCreator

Class : rsscalCreator

constructor for rsscalCreator object.

format:
rsscalCreator( string title, string link, string description [, string version ] ) (preferred)

rsscalCreator()

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required

[index]

2.2 CHANNEL MANAGEMENT METHODS

rsscalChannel

Class : rsscalChannel

Constructor for rsscalChannel object.

format:
rsscalChannel( string title, string link, string desc )

example:
$c = new rsscalCreator();
.. .
$channel = new rsscalChannel( $title, $link, $desc ); // required, required, required
$c->setChannel( $channel );
.. .

[index]

addElement

Class : rsscalChannel

Add new (optional) element.

format:
addElement( string elementName, string elementContent [, array attributes ] )

example:
$c = new rsscalCreator();
.. .
$channel = new rsscalChannel( $title, $link, $desc ); // required, required, required
$channel->addElement( 'dc:date', $date ); // optional element, name required, content required
$channel->addElement( 'dc:rights', $copy ); // optional element, name required, content required
$c->setChannel( $channel );
.. .

[index]

setChannel

Class : rsscalCreator

Set channel element for rsscalCreator instans.

format:
setChannel( object channelElement )

example:
$c = new rsscalCreator();
.. .
$channel = new rsscalChannel( $title, $link, $desc ); // required, required, required
$channel->addElement( 'dc:date', $date ); // optional element, name required, content required
$channel->addElement( 'dc:rights', $copy ); // optional element, name required, content required
$c->setChannel( $channel );
.. .

[index]

setChannelAttribute

Class : rsscalCreator

Set channel attribute for rsscalCreator instans.
Link content is taken if attribute is not set.

format:
setChannelAttribute( string attribute )

example:
$c = new rsscalCreator();
.. .
$c->setChannelAttribute( $attribute );
.. .

[index]

setChannelDescription

Class : rsscalCreator

Set channel element description for rsscalCreator instans.
Overwrites any previous set description.

format:
setChannelDescription( string description )

example:
$c = new rsscalCreator();
.. .
$c->setChannelDescription( $description );
.. .

[index]

setChannelElement

Class : rsscalCreator

Set channel element for rsscalCreator instans.

format:
setChannelElement( string elementName, string elementContent [, array elementAttribute ] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
$c->setChannelElement( 'dc:rights', $copy ); // optional element, name required, content required
.. .

[index]

setChannelLink

Class : rsscalCreator

Set channel element link for rsscalCreator instans.
Overwrites any previous set link.

format:
setChannelLink( string link )

example:
$c = new rsscalCreator();
.. .
$c->setChannelLink( $link );
.. .

[index]

setChannelTitle

Class : rsscalCreator

Set channel element title for rsscalCreator instans.
Overwrites any previous set title.

format:
setChannelTitle( string title )

example:
$c = new rsscalCreator();
.. .
$c->setChannelTitle( $title );
.. .

[index]

setImage

Class : rsscalCreator

Set channel image for rsscalCreator instans.

format:
setImage( object imageElement )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$image = new rsscalImage( $imageTitle, $imageUrl, $imageLink ); // required, required, required
$c->setImage( $image );
.. .

[index]

setTextinput

Class : rsscalCreator

Set channel textinput for rsscalCreator instans.

format:
setTextinput( object textinputElement )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$textinput = new rsscalTextinput( $textinputTitle, $textinputDescription, $textinputName, $textinputLink ); // required, required, required, required
$c->setTextinput( $textinput );
.. .

[index]

2.3 ITEM MANAGEMENT METHODS

rsscalItem

Class : rsscalItem

Constructor for rsscalItem object.

format:
rsscalItem( string title, string link [, string description ] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$item = new rsscalItem( $itemTitle, $itemLink, $itemDescription ); // required, required, optional
$c->addItem( $item );
.. .

[index]

addElement

Class : rsscalItem

Add new (optional) element.

format:
addElement( string elementName, string elementContent [, array attributes ] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$item = new rsscalItem( $itemTitle, $itemLink, $itemDescription ); // required, required, optional
$item->addElement( 'dc:date', $date ); // optional element, name required, content required
$item->addElement( 'dc:rights', $copy ); // optional element, name required, content required
$c->addItem( $item );
.. .

[index]

addItem

Class : rsscalCreator

Add item element.

format:
addItem( object rsscalItem )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$item = new rsscalItem( $itemTitle, $itemLink, $itemDescription ); // required, required, optional
$item->addElement( 'dc:date', $date ); // optional element, name required, content required
$item->addElement( 'dc:rights', $copy ); // optional element, name required, content required
$c->addItem( $item );
.. .

[index]

2.4 IMAGE MANAGEMENT METHODS

rsscalImage

Class : rsscalImage

Constructor for rsscalImahe object.

format:
rsscalImage( string title, string url, string link )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$image = new rsscalImage( $imageTitle, $imageUrl, $imageLink ); // required, required, required
$c->setImage( $image );
.. .

[index]

addElement

Class : rsscalImage

Add new (optional) element.

format:
addElement( string elementName, string elementContent [, array attributes ] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$image = new rsscalImage( $imageTitle, $imageUrl, $imageLink ); // required, required, required
$image->addElement( 'dc:date', $date ); // optional element, name required, content required
$image->addElement( 'dc:rights', $copy ); // optional element, name required, content required
$c->setImage( $image );
.. .

[index]

setImage

Class : rsscalCreator

Set channel image for rsscalCreator instans.

format:
setImage( object imageElement )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$image = new rsscalImage( $imageTitle, $imageUrl, $imageLink ); // required, required, required
$c->setImage( $image );
.. .

[index]

2.5 TEXTINPUT MANAGEMENT METHODS

rsscalTextinput

Class : rsscalTextinput

Constructor for rsscalTextinput object.

format:
rsscalTextinput( string title, string description, string name, string link )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$textinput = new rsscalTextinput( $textinputTitle, $textinputDescription, $textinputName, $textinputLink ); // required, required, required, required
$c->setTextinput( $textinput );
.. .

[index]

addElement

Class : rsscalTextinput

Add new (optional) element.

format:
addElement( string elementName, string elementContent [, array attributes ] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$textinput = new rsscalTextinput( $textinputTitle, $textinputDescription, $textinputName, $textinputLink ); // required, required, required, required
$textinput->addElement( 'dc:date', $date ); // optional element
$textinput->addElement( 'dc:language', $lang ); // optional element
$c->setTextinput( $textinput );
.. .

[index]

setTextinput

Class : rsscalCreator

Set channel textinput for rsscalCreator instans.

format:
setTextinput( object textinputElement )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
$textinput = new rsscalTextinput( $textinputTitle, $textinputDescription, $textinputName, $textinputLink ); // required, required, required, required
$c->setTextinput( $textinput );
.. .

[index]

2.6 FEED MANAGEMENT METHODS

createRSS

Class : rsscalCreator

Creates formatted output for rsscalCreator instance
Returns string, feed content

format:
createRSS( [version] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
.. .
$string = $c->createRSS();
echo $string; // display created feed content, testing?

[index]

returnRSS

Class : rsscalCreator

a HTTP redirect header is sent with created and saved file.

format:
returnRSS( [string directory [, string filename [, string delimiter ]]] )

example:
$c = new rsscalCreator( $title, $link, $desc ); // required, required, required
.. .
.. .
$c->returnRSS( $cacheFolder );

[index]

useCachedRSS

Class : rsscalCreator

if recent version of feed file exists (default 3600 sec), an HTTP redirect header is sent.

format:
useCachedRSS( string directory, string filename, string delimiter [, int timeout ] )

[index]

2.7 FILE MANAGEMENT METHODS

getFilename

Class : rsscalCreator

Get feed file name.
Returns array : directory, filename, filesize.

format:
setFilename( [string directory [, string filename [, string delimiter ]]] )

[index]

saveRSS

Class : rsscalCreator

Create and save edited rsscalCreator content to file
Returns FALSE (file not writeable) /array : directory, filename, filesize

saveRSS( [string directory [, string filename [, string delimiter ]]] )

[index]

setFilename

Class : rsscalCreator

Set feed file name (default date( 'YmdHis' ).'.rss') (create empty file ).
Returns FALSE if not writable else TRUE.

format:
setFilename( [string directory [, string filename [, string delimiter ]]] )

[index]

3. COPYRIGHT AND LICENSE

Copyright

rsscalCreator class
originally (c) Kjell-Inge Gustafsson
www.kigkonsult.se/rsscalCreator/index.php
ical@kigkonsult.se

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or download it here.

[index]