require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id $v = new vcalendar( $config ); // create a new calendar instance $tz = "Europe/Stockholm"; // define time zone $v->setProperty( "method", "PUBLISH" ); // required of some calendar software $v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software $v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software $v->setProperty( "X-WR-TIMEZONE", $tz ); // required of some calendar software .. . $xprops = array( "X-LIC-LOCATION" => $tz ); // required of some calendar software iCalUtilityFunctions::createTimezone( $v, $tz, $xprops ); // create timezone component(-s) opt. 1 .. . // based on present date .. . $vevent = & $v->newComponent( "vevent" ); // create an event calendar component $vevent->setProperty( "dtstart", array( "year"=>2007, "month"=>4, "day"=>1, "hour"=>19, "min"=>0, "sec"=>0 )); $vevent->setProperty( "dtend", array( "year"=>2007, "month"=>4, "day"=>1, "hour"=>22, "min"=>30, "sec"=>0 )); $vevent->setProperty( "LOCATION", "Central Placa" ); // property name - case independent $vevent->setProperty( "summary", "PHP summit" ); $vevent->setProperty( "description", "This is a description" ); $vevent->setProperty( "comment", "This is a comment" ); $vevent->setProperty( "attendee", "attendee1@icaldomain.net" ); .. . $valarm = & $vevent->newComponent( "valarm" ); // create an event alarm $valarm->setProperty("action", "DISPLAY" ); $valarm->setProperty("description", $vevent->getProperty( "description" ); .. . // reuse the event description .. . $d = sprintf( '%04d%02d%02d %02d%02d%02d', 2007, 3, 31, 15, 0, 0 ); iCalUtilityFunctions::transformDateTime( $d, $tz, "UTC", "Ymd\THis\Z"); $valarm->setProperty( "trigger", $d ); // create alarm trigger (in UTC datetime) .. . $vevent = & $v->newComponent( "vevent" ); // create next event calendar component $vevent->setProperty( "dtstart", "20070401", array("VALUE" => "DATE"));// alt. date format, now for an all-day event $vevent->setProperty( "organizer" , "boss@icaldomain.com" ); $vevent->setProperty( "summary", "ALL-DAY event" ); $vevent->setProperty( "description", "This is a description for an all-day event" ); $vevent->setProperty( "resources", "COMPUTER PROJECTOR" ); $vevent->setProperty( "rrule", array( "FREQ" => "WEEKLY", "count" => 4));// weekly, four occasions $vevent->parse( "LOCATION:1CP Conference Room 4350" ); // supporting parse of strict rfc5545 formatted text .. . .. .// all calendar components are described in rfc5545 .. .// a complete iCalcreator function list (ex. setProperty) in iCalcreator manual .. . iCalUtilityFunctions::createTimezone( $v, $tz, $xprops); // create timezone component(-s) opt. 2 .. . // based on all start dates in events (i.e. dtstart) .. . .. .
require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id, required if any component UID is missing $v = new vcalendar( $config ); // create a new calendar instance /* start parse of local iCal file */ $config = array( "directory" => "calendar", "filename" => "file.ics" ); $v->setConfig( $config ); // set directory and file name $v->parse(); /* start parse of remote iCal file */ $v->setConfig( "url", "http://www.aDomain.net/file.ics" ); // iCalcreator also support parse of remote files $v->parse(); $v->setProperty( "method", "PUBLISH" ); // required of some calendar software $v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software $v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software $v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software .. . $v->sort(); // ensure start date order .. . .. . // continue process (edit, parse,select) the iCalcreator instance .. .
require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id, required if any component UID is missing .. . $filename = 'xmlfile.xml'; // use a local xCal file // $filename = 'http://kigkonsult.se/xcal.php?a=1&b=2&c=3';// or a remote xCal resource if( FALSE === ( $v = XMLfile2iCal( $filename, $config ))) // convert the XML resource to an iCalcreator instance exit( "Error when parsing $filename" ); .. . .. . // continue process (edit, parse,select) the iCalcreator instance .. .
require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se", "directory" => "calendar", "filename" => "file.ics" ); // set the (site) unique id, the import directory and file name $v = new vcalendar( $config ); // create a new calendar instance $v->parse(); $v->setProperty( "method", "PUBLISH" ); // required of some calendar software $v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software $v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software $v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software while( $vevent = $v->getComponent( "vevent" )) { // read events, one by one $uid = $vevent->getProperty( "uid" ); // uid required, one occurrence (unique id/key for component) .. . $dtstart = $vevent->getProperty( "dtstart" ); // dtstart required, one occurrence .. . if( $description = $vevent->getProperty( "description", 1 )) { // description optional, first occurrence .. . // edit the description $vevent->setProperty( "description", $description, FALSE, 1 ); // update/replace the description } while( $comment = $vevent->getProperty( "comment" )) { // comment optional, may occur more than once .. . // manage comments } .. . while( $vevent->deleteProperty( "attendee" )) continue; // remove all ATTENDEE properties .. . .. . $v->setComponent ( $vevent, $uid ); // update/replace event in calendar with UID as key } .. . .. .// a complete iCalcreator function list (ex. getProperty, deleteProperty) in iCalcreator manual .. .
require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id $v = new vcalendar( $config ); // create a new calendar instance $v->setConfig( "url", "http://www.aDomain.net/file.ics" ); // iCalcreator also support remote files $v->parse(); $v->sort(); // ensure start date order $v->setProperty( "method", "PUBLISH" ); // required of some calendar software $v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software $v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software $v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software
$eventArray = $v->selectComponents(); // select components occurring today // (including components with recurrence pattern) foreach( $eventArray as $year => $yearArray) { foreach( $yearArray as $month => $monthArray ) { foreach( $monthArray as $day => $dailyEventsArray ) { foreach( $dailyEventsArray as $vevent ) { $currddate = $event->getProperty( "x-current-dtstart" ); // if member of a recurrence set (2nd occurrence etc) // returns array( "x-current-dtstart" // , <(string) date("Y-m-d [H:i:s][timezone/UTC offset]")>) $dtstart = $vevent->getProperty( "dtstart" ); // dtstart required, one occurrence, (orig. start date) $summary = $vevent->getProperty( "summary" ); $description = $vevent->getProperty( "description" ); .. . .. . } } } }
$valueOccur = $v->getProperty( "RESOURCES" ); // fetch specific property (unique) values and occurrences // ATTENDEE, CATEGORIES, DTSTART, LOCATION, // ORGANIZER, PRIORITY, RESOURCES, STATUS, // SUMMARY, UID foreach( $valueOccur as $uniqueValue => $occurCnt ) { echo "The RESOURCES value <b>$uniqueValue</b> occurs <b>$occurCnt</b> times<br />"; .. . }
$selectSpec = array( "CATEGORIES" => "course1" ); $specComps = $v->selectComponents( $selectSpec ); // selects components based on specific property value(-s) // ATTENDEE, CATEGORIES, LOCATION, ORGANIZER, // PRIORITY, RESOURCES, STATUS, SUMMARY, UID foreach( $specComps as $comp ) { .. . }
require_once( "iCalcreator.class.php" ); $config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id $v = new vcalendar( $config ); // create a new calendar instance $v->setProperty( "method", "PUBLISH" ); // required of some calendar software $v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software $v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software $v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software .. . .. . // continue process (edit, parse,select) the iCalcreator instance .. .
.. . $v->returnCalendar(); // redirect calendar file to browser
.. . $config = array( "directory" => "depot", "filename" => "calendar.ics" ); $v->setConfig( $config ); // set output directory and file name $v->saveCalendar(); // save calendar to (local) file .. .
.. . $xmlstr = iCal2XML( $v ); // create well-formed XML, rfc6321 ...