At github, you will found the latest 2.30.5 (tag) release.
Howto summary
A short (v2.30) summary how to use iCalcreator: create, parse, edit, select and output,
click on the to expand/minimize each section.
CREATE
namespace Kigkonsult\Icalcreator;
//
$tz = "Europe/Stockholm";
//
//
$config = [
Vcalendar::UNIQUE_ID => "kigkonsult.se",
//
Vcalendar::TZID => $tz
];
//
$calendar = new Vcalendar( $config );
//
$calendar->setMethod( "PUBLISH" );
$calendar->setXprop( "x-wr-calname", "Calendar Sample" );
$calendar->setXprop( "X-WR-CALDESC", "Calendar Description" );
$calendar->setXprop( "X-WR-TIMEZONE", $tz );
//
$vevent = $calendar->newVevent();
//
$vevent->setDtstart(
new DateTime( '2017-04-01 19:00:00' ),
new DateTimezone( $tz )
);
//
$vevent->setDtend(
new DateTime( '2017-04-01 22:30:00'),
new DateTimezone( $tz )
);
$vevent->setLocation( "Central Placa" );
$vevent->setSummary( "PHP summit" );
$vevent->setDescription( "This is a description" );
$vevent->setComment( "This is a comment" );
$vevent->setAttendee( "attendee1@icaldomain.net" );
//
$valarm = $vevent->newValarm();
$valarm->setAction( Vcalendar::DISPLAY );
//
$valarm->setDescription( $vevent->getProperty( Vcalendar::DESCRIPTION ));
//
$valarm->setTrigger( new DateTime( "2017-04-01 08:00:00 UTC"));
//
$vevent = $calendar->newVevent();
//
$vevent->setDtstart( "20170401", [ Vcalendar::VALUE => Vcalendar::DATE ] );
$vevent->setOrganizer( "boss@icaldomain.com" );
$vevent->setSummary( "ALL-DAY event" );
$vevent->setDescription( "An all-day event" );
$vevent->setResources( "Full attension" );
//
$vevent->setRRule(
[
Vcalendar::FREQ => Vcalendar::WEEKLY,
Vcalendar::COUNT => 4
]
);
//
$vevent->parse( "LOCATION:1CP Conference Room 4350" );
//
//
$calendarString = $vcalendar
//
->vtimezonePopulate()
//
->createCalendar();
[top] [up]
PARSE
iCal, rfc5545 / rfc2445
create iCalcreator object instance
// set the (site) unique id,
// required if any component UID is missing!!
$config = [ Vcalendar::UNIQUE_ID => "kigkonsult.se" ];
// create a new calendar instance
$calendar = new vcalendar( $config );
.. .
then parse of local file
//
$iCalContent = file_get_contents( "calendar.ics" );
//
$vcalendar->parse( $iCalContent );
//
...
xCal, rfc6321 (XML)
How to convert (file) XML resource to an iCalcreator object instance.
use Kigkonsult\Icalcreator\Vcalendar;
use Kigkonsult\Icalcreator\Util\IcalXMLFactory;
//
//
$config = [ Vcalendar::UNIQUE_ID => "kigkonsult.se" ];
//
$filename = "xmlfile.xml";
//
$iCalContent = file_get_contents( $filename );
//
try {
$calendar = IcalXMLFactory::XML2iCal( $iCalContent, $config );
}
catch( Exception $e ) {
exit( "XML parse error" );
}
//
...
...
[top] [up]
EDIT
//
$calendar = new Vcalendar(
[
Vcalendar::UNIQUE_ID => "kigkonsult.se"
]
);
//
$iCalContent = file_get_contents( "calendar.ics" );
//
$calendar->parse( $iCalContent )
$calendar->setMethod( Vcalendar::PUBLISH );
$calendar->setXprop( Vcalendar::X_WR_CALNAME, "Calendar Sample" );
$calendar->setXprop( Vcalendar::X_WR_CALDESC, "Calendar Description" );
$calendar->setXprop( Vcalendar::X_WR_TIMEZONE, "Europe/Stockholm" );
//
while( $vevent = $calendar->getComponent( Vcalendar::VEVENT )) {
//
$uid = $vevent->getUid();
//
$dtstart = $vevent->getDtstart();
//
if( false !== ( $description = $vevent->getDescription())) {
//
//
$vevent->setDescription( $description );
}
//
while( $comment = $vevent->getComment()) {
.. .
}
//
while( $vevent->deleteAttendee()) {
continue;
}
//
//
$calendar->setComponent ( $vevent, $uid );
}
[top] [up]
SELECT
//
$calendar = new Vcalendar(
[
Vcalendar::UNIQUE_ID => "kigkonsult.se"
]
);
//
$url = "http://www.ical.net/calendars/calendar.ics";
$iCalContent = UrlRsrc::getContent( $url );
$calendar->parse( $iCalContent );
//
$calendar->setMethod( Vcalendar::PUBLISH );
$calendar->setXprop( Vcalendar::X_WR_CALNAME, "Calendar Sample" );
$calendar->setXprop( Vcalendar::X_WR_CALDESC, "Calendar Description" );
$calendar->setXprop( Vcalendar::X_WR_TIMEZONE, "Europe/Stockholm" );
Select components based on specific date period
//
//
$eventArray = $calendar->selectComponents();
foreach( $eventArray as $year => $yearArray) {
foreach( $yearArray as $month => $monthArray ) {
foreach( $monthArray as $day => $dailyEventsArray ) {
foreach( $dailyEventsArray as $vevent ) {
//
$currddate = $event->getProperty(
Vcalendar::X_CURRENT_DTSTART
);
//
//
//
//
//
$dtstart = $vevent->getDtstart();
$summary = $vevent->getSummary();
$description = $vevent->getDescription();
.. .
.. .
}
}
}
}
Select specific property values
//
//
//
//
//
//
$selectSpec = [ Vcalendar::CATEGORIES => "course1" ];
$specComps = $calendar->selectComponents( $selectSpec );
foreach( $specComps as $comp ) {
.. .
}
*) Using the non-standard directive "GEOLOCATION", iCalcreator returns output
supporting ISO6709 "Standard representation of geographic point location by coordinates",
by combining the "LOCATION" and "GEO" property values (only if "GEO" is set).
Select components based on specific property value
//
//
//
//
//
//
$selectSpec = [ Vcalendar::CATEGORIES => "course1" ];
$specComps = $calendar->selectComponents( $selectSpec );
foreach( $specComps as $comp ) {
.. .
}
.. .
[top] [up]
OUTPUT
.. .
//
$calendar = new Vcalendar(
[
Vcalendar::UNIQUE_ID => "kigkonsult.se"
]
);
.. .
// required of some calendar software
$calendar->setMethod( Vcalendar::PUBLISH );
$calendar->setXprop( Vcalendar::X_WR_CALNAME, "Calendar Sample" );
$calendar->setXprop( Vcalendar::X_WR_CALDESC, "Calendar Description" );
$calendar->setXprop( Vcalendar::X_WR_TIMEZONE, "Europe/Stockholm" );
.. .
// parse calendar file(s)
// and/or edit/create calendar components.. .
.. .
opt 1
Get calendar as string.
$calendarStr = $calendar->createCalendar();
opt 2
Redirect calendar file to browser.
$calendar->returnCalendar();
exit();
opt 3
Save calendar to file.
//
$calendarStr = $calendar->createCalendar();
//
file_put_contents( "calendar.ics", $calendarStr );
opt 4
Create well-formed XML, rfc6321 (as string).
$xmlstr = Kigkonsult\Icalcreator\Util\IcalXMLFactory::iCal2XML( $calendar);
opt 5
Create a json string.
$xmlstr = Kigkonsult\Icalcreator\Util\IcalXMLFactory::iCal2XML( $calendar);
$json = json_encode( simplexml_load_string( $xmlstr ));
[top] [up]
iCalcreator used in.. .
Please use the contact page
if you would like to
- report your site / application / module / plugin as a new entry in the list
- report a dead link
- tell us what iCalcreator is missing!!
[top]
Create/edit/show iCal files
You can test iCalcreator online and create iCal test files on-the-fly,
using tiCalFile,
example of how to employ iCalcreator in software development.
An example how to present and display iCal calendar file information,
tinycal,
using iCalcreator class in the server back end software.
[top]
[top]