$modules = $data->Activities->Course->Module;
foreach ($modules as $module) {
    $classes = $module->Activity;
    foreach ($classes as $class) {
        $date = $class->Date;
        $StartTime = $class->StartTime;
        $EndTime = $class->EndTime;
        $location = $class->Locations->Location;
        $lecturers = $class->Staff->Person;
        if (count($lecturers) > 1) {
            $lecturersString = "";
            foreach ($lecturers as $lecturer) {
                //print_r($lecturer);
                $lecturersString .= $lecturer->Name . " ";
            }
        } else {
            $lecturersString = $lecturers->Name;
        }
        echo "BEGIN:VEVENT\n";
        echoProperty("DTSTART", getIcalDate(strtotime("{$date->Day}-{$date->Month}-{$date->Year} {$StartTime->Hours}:{$StartTime->Minutes}")));
        echoProperty("DTEND", getIcalDate(strtotime("{$date->Day}-{$date->Month}-{$date->Year} {$EndTime->Hours}:{$EndTime->Minutes}")));
        echoProperty("DTSTAMP", getIcalDate(time()));
        echoProperty("SUMMARY", $class->Description);
        echoProperty("LOCATION", $location->AbbreviatedName);
        echoProperty("DESCRIPTION", $lecturersString);
        echoProperty("UID", $class->Guid);
        echo "END:VEVENT\n";
    }
}
?>
END:VCALENDAR
Exemple #2
0
/**
 * creates a single iCalendar formatted event.
 * The events are full day anually recurring events.
 * The events are set to CLASS:CONFIDENTIAL, and should therefore be transparent
 * to other users sharing your calendar (for example the time will show you as
 * available to other Outlook users)
 * @param string $data the data to be formatted
 * @return	the formatted string
 * @TODO Fix ‎ tags by using proper unicode 200E code. Since the iCalendar does not user HTML, the ‎ tag should not be used. This should only be an issue when Hebrew dates are used
 */
function getIcalRecord($date, $summary, $description, $URL = "")
{
    $dtstamp = getIcalTS();
    //current TS
    $startDate = getIcalDate($date);
    $endDate = getIcalDate($date, true);
    //not needed as per RFC2445 spec
    $iCalString = "\r\nBEGIN:VEVENT" . "\r\nDTSTAMP:{$dtstamp}" . "\r\nDTSTART;VALUE=DATE:{$startDate}" . "\r\nDTEND;VALUE=DATE:{$endDate}" . "\r\n" . formatIcalData("SUMMARY:{$summary}") . "\r\n" . formatIcalData("DESCRIPTION:{$description}") . "\r\nRRULE:FREQ=YEARLY" . "\r\nCLASS:CONFIDENTIAL" . "\r\nTRANSP:TRANSPARENT" . "\r\nUID:" . PGV_PHPGEDVIEW . '-' . generate_guid() . "\r\nCATEGORIES:" . PGV_PHPGEDVIEW . " Events" . "\r\n" . formatIcalData("URL:{$URL}") . "\r\nEND:VEVENT";
    return $iCalString;
}