Ejemplo n.º 1
0
 /**
  * @coversNothing
  */
 public function testExample3()
 {
     $timeZone = new \DateTimeZone('Europe/Berlin');
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
     // 2. Create an event
     $vEvent = new \Eluceo\iCal\Component\Event('123456');
     $vEvent->setDtStart(new \DateTime('2012-12-31', $timeZone));
     $vEvent->setDtEnd(new \DateTime('2012-12-31', $timeZone));
     $vEvent->setNoTime(true);
     $vEvent->setIsPrivate(true);
     $vEvent->setSummary('New Year’s Eve');
     // Set recurrence rule
     $recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
     $recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
     $recurrenceRule->setInterval(1);
     $vEvent->setRecurrenceRule($recurrenceRule);
     // Adding Timezone (optional)
     $vEvent->setUseTimezone(true);
     // 3. Add event to calendar
     $vCalendar->addComponent($vEvent);
     $lines = array('/BEGIN:VCALENDAR/', '/VERSION:2\\.0/', '/PRODID:www\\.example\\.com/', '/X-PUBLISHED-TTL:P1W/', '/BEGIN:VEVENT/', '/UID:123456/', '/DTSTART;TZID=Europe\\/Berlin;VALUE=DATE:20121231/', '/SEQUENCE:0/', '/TRANSP:OPAQUE/', '/DTEND;TZID=Europe\\/Berlin;VALUE=DATE:20121231/', '/SUMMARY:New Year’s Eve/', '/CLASS:PRIVATE/', '/RRULE:FREQ=YEARLY;INTERVAL=1/', '/X-MICROSOFT-CDO-ALLDAYEVENT:TRUE/', '/DTSTAMP:20\\d{6}T\\d{6}Z/', '/END:VEVENT/', '/END:VCALENDAR/');
     foreach (explode("\n", $vCalendar->render()) as $key => $line) {
         $this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);
         $this->assertRegExp($lines[$key], $line);
     }
 }
Ejemplo n.º 2
0
<?php

// require files
require_once '../src/Eluceo/iCal/Component.php';
require_once '../src/Eluceo/iCal/PropertyBag.php';
require_once '../src/Eluceo/iCal/Property.php';
require_once '../src/Eluceo/iCal/Component/Calendar.php';
require_once '../src/Eluceo/iCal/Component/Event.php';
// set default timezone (PHP 5.4)
date_default_timezone_set('Europe/Berlin');
// 1. Create new calendar
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
// 2. Create an event
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart(new \DateTime('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
$vEvent->setNoTime(true);
$vEvent->setSummary('Christmas');
// Adding Timezone (optional)
$vEvent->setUseTimezone(true);
// 3. Add event to calendar
$vCalendar->addEvent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');
// 5. Output
echo $vCalendar->render();
Ejemplo n.º 3
0
function makeICalendar($row)
{
    $vEvent = new \Eluceo\iCal\Component\Event();
    $vEvent->setDtStart(new \DateTime($row['startDate']));
    $vEvent->setDtEnd(new \DateTime($row['endDate']));
    $vEvent->setNoTime(false);
    $vEvent->setSummary($row['name'] . " 2016 New Years Levee");
    $vEvent->setLocation($row['location_name'] . "\n" . $row['location_address'], $row['location_name'], $row['latitude'] . "," . $row['longitude']);
    $vEvent->setUseTimezone(true);
    return $vEvent;
}
Ejemplo n.º 4
0
 public function generateIcal()
 {
     // set default timezone (PHP 5.4)
     date_default_timezone_set('Europe/Berlin');
     $ical_name = 'HSG Wesel - Gesamtspielplan';
     $ical_calid = 'hsg_wesel_1516_total';
     $ics_file_name = 'hsg_wesel_1516_total.ics';
     $team_info = $this->getTeamInfo();
     if (is_array($team_info)) {
         $ical_name = 'HSG Wesel - Saison 2015/16 - ' . $team_info['team'];
         $ical_calid = 'hsg_wesel_1516_' . $team_info['liga_id'];
         $ics_file_name = 'hsg_wesel_1516_' . $this->getTeam() . '.ics';
     } else {
         switch ($this->art) {
             case '188':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Heim';
                 $ical_calid = 'hsg_wesel_1516_1330105011_heim';
                 $ics_file_name = 'hsg_wesel_1516_spielplan_heim' . '.ics';
                 break;
             case '199':
                 $ical_name = 'HSG Wesel - Saison 2015/16 - Spielplan Auswärts';
                 $ical_calid = 'hsg_wesel_1516_1330105011_auswaerts';
                 $ics_file_name = 'hsg_wesel_1516_auswaerts' . '.ics';
                 break;
         }
     }
     // 1. Create new calendar
     $vCalendar = new \Eluceo\iCal\Component\Calendar('HSG Wesel SIS-Handball ICS-Generator');
     $vCalendar->setName($ical_name);
     $vCalendar->setDescription('HSG Wesel / photominister.de');
     $vCalendar->setCalId($ical_calid);
     $vCalendar->setMethod('PUBLISH');
     // 2. Create an event
     // $this->framework->dump($this->art);
     if (count($this->xml->Spiel) > 0) {
         foreach ($this->xml->Spiel as $spiel) {
             $element = $this->getHash($spiel);
             $show_heim = substr($spiel->Heim, 0, 9) == 'HSG Wesel';
             $show_gast = substr($spiel->Gast, 0, 9) == 'HSG Wesel';
             switch ($this->art) {
                 case '188':
                     $cond = $show_heim;
                     break;
                 case '199':
                     $cond = $show_gast;
                     break;
                 default:
                     $cond = $show_heim || $show_gast;
                     break;
             }
             if ($cond) {
                 $description = $spiel->LigaName . '..... www.hsg-wesel.de ..... www.handballinwesel.de ..... www.facebook.com/hsgwesel';
                 $description = str_replace("\r\n", "\\n", $description);
                 $vEvent = new \Eluceo\iCal\Component\Event();
                 $vEvent->setDtStart(new \DateTime($spiel->SpielVon));
                 $vEvent->setDtEnd(new \DateTime($spiel->SpielBis));
                 $vEvent->setSummary($spiel->Heim . ' - ' . $spiel->Gast);
                 $vEvent->setDescription($description);
                 $vEvent->setLocation($spiel->HallenName . ', ' . $spiel->HallenStrasse . ', ' . $spiel->HallenOrt);
                 $vEvent->setUseTimezone(TRUE);
                 // 3. Add event to calendar
                 $vCalendar->addComponent($vEvent);
                 unset($vEvent);
             }
         }
     }
     // 4. Set headers
     header('Content-Type: text/calendar; charset=utf-8');
     header('Content-Disposition: attachment; filename="' . $ics_file_name . '"');
     // 5. Output
     echo $vCalendar->render();
     exit;
 }