当前位置: 首页>>代码示例>>PHP>>正文


PHP VCalendar::add方法代码示例

本文整理汇总了PHP中Sabre\VObject\Component\VCalendar::add方法的典型用法代码示例。如果您正苦于以下问题:PHP VCalendar::add方法的具体用法?PHP VCalendar::add怎么用?PHP VCalendar::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\VObject\Component\VCalendar的用法示例。


在下文中一共展示了VCalendar::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render(Diary $diary)
 {
     $vcalendar = new VCalendar();
     $vcalendar->remove('PRODID');
     $vcalendar->add('PRODID', '-//Camdram//NONSGML Show Diary//EN');
     foreach ($diary->getEvents() as $event) {
         $start_time = null;
         $rrule = array();
         if ($event instanceof MultiDayEventInterface) {
             $start_time = new \DateTime($event->getStartDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s'));
             $last_start_time = new \DateTime($event->getEndDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s'));
             $rrule = 'FREQ=DAILY;UNTIL=' . $last_start_time->format('Ymd\\THis\\Z');
         } elseif ($event instanceof SingleDayEventInterface) {
             $start_time = new \DateTime($event->getDate() . ' ' . $event->getStartTime()->format('H:i:s'));
         }
         if ($start_time) {
             $utc = new \DateTimeZone('UTC');
             $start_time->setTimezone($utc);
             $end_time = clone $start_time;
             $end_time->modify('+2 hours');
             $dtstamp = clone $event->getUpdatedAt();
             $dtstamp->setTimezone($utc);
             $params = array('SUMMARY' => $event->getName(), 'LOCATION' => $event->getVenue(), 'UID' => $event->getUid(), 'DTSTAMP' => $dtstamp, 'DTSTART' => $start_time, 'DURATION' => 'PT2H00M00S', 'DESCRIPTION' => $event->getDescription());
             if ($rrule) {
                 $params['RRULE'] = $rrule;
             }
             $vcalendar->add('VEVENT', $params);
         }
     }
     return $vcalendar->serialize();
 }
开发者ID:dstansby,项目名称:camdram,代码行数:31,代码来源:ICalRenderer.php

示例2: menuIdAction

 /**
  * @Route("/{id}.ics")
  * @Method({"GET"})
  */
 public function menuIdAction($id)
 {
     $api = new ApiController();
     $api->setContainer($this->container);
     $menu = $api->menuIdAction($id);
     if ($menu->getStatusCode() !== 200) {
         return new Response('Calendar not found', 404);
     }
     $json = json_decode($menu->getContent(), true);
     $headers = array('Content-Type' => 'text/calendar; charset=utf-8', 'Content-Disposition' => 'attachment; filename="' . $id . '.ics');
     $vCalendar = new VCalendar();
     foreach ($json['data'] as $event) {
         $vEvent = $vCalendar->add('VEVENT');
         # Timezone
         $timezone = new DateTimeZone('Europe/Paris');
         # Start and end
         $start = new DateTime();
         $start->setTimestamp($event['start']);
         $start->setTimezone($timezone);
         $end = new DateTime();
         $end->setTimestamp($event['end']);
         $end->setTimezone($timezone);
         $name = implode(', ', $event['meals']);
         $description = implode(', ', $event['meals']);
         $vEvent->add('UID', uniqid('menu_'));
         $vEvent->add('DTSTART', $start);
         $vEvent->add('DTEND', $end);
         $vEvent->add('SUMMARY', $name);
         $vEvent->add('DESCRIPTION', $description);
     }
     $calendar = $vCalendar->serialize();
     return new Response($calendar, 200, $headers);
 }
开发者ID:gnkam,项目名称:agenda-etudiant,代码行数:37,代码来源:IcsController.php

示例3: testAlarmWayBefore

 function testAlarmWayBefore()
 {
     $vcalendar = new VObject\Component\VCalendar();
     $vevent = $vcalendar->createComponent('VEVENT');
     $vevent->DTSTART = '20120101T120000Z';
     $vevent->UID = 'bla';
     $valarm = $vcalendar->createComponent('VALARM');
     $valarm->TRIGGER = '-P2W1D';
     $vevent->add($valarm);
     $vcalendar->add($vevent);
     $filter = array('name' => 'VCALENDAR', 'is-not-defined' => false, 'time-range' => null, 'prop-filters' => array(), 'comp-filters' => array(array('name' => 'VEVENT', 'is-not-defined' => false, 'time-range' => null, 'prop-filters' => array(), 'comp-filters' => array(array('name' => 'VALARM', 'is-not-defined' => false, 'prop-filters' => array(), 'comp-filters' => array(), 'time-range' => array('start' => new \DateTime('2011-12-10'), 'end' => new \DateTime('2011-12-20')))))));
     $validator = new CalendarQueryValidator();
     $this->assertTrue($validator->validate($vcalendar, $filter));
 }
开发者ID:samj1912,项目名称:repo,代码行数:14,代码来源:CalendarQueryVAlarmTest.php

示例4: render

 /**
  *
  * @param Response $response
  * @param array $data
  * @param int $status
  *
  * @return ResponseInterface
  */
 public function render(ResponseInterface $response, array $data = [], $status = 200)
 {
     $icalendar = new VCalendar();
     foreach ($data['cfps'] as $cfp) {
         $cfpStart = new \DateTime($cfp['dateCfpStart']);
         $cfpEnd = new \DateTime($cfp['dateCfpEnd']);
         $lastChange = new \DateTime($cfp['lastChange']);
         $lastChange->setTimezone(new \DateTimeZone('UTC'));
         if ($cfp['timezone']) {
             $cfpStart->setTimezone(new \DateTimeZone($cfp['timezone']));
             $cfpEnd->setTimezone(new \DateTimeZone($cfp['timezone']));
         }
         $icalendar->add('VEVENT', ['SUMMARY' => $cfp['name'], 'DTSTART' => $cfpStart, 'DTEND' => $cfpEnd, 'URL' => $cfp['uri'], 'DTSTAMP' => $lastChange, 'UID' => $cfp['_rel']['cfp_uri'], 'DESCRIPTION' => $cfp['description'], 'GEO' => round($cfp['latitude'], 6) . ';' . round($cfp['longitude'], 6), 'LOCATION' => $cfp['location']]);
     }
     $response = $response->withHeader('Content-Type', 'text/calendar');
     $stream = $response->getBody();
     $stream->write($icalendar->serialize());
     return $response->withBody($stream);
 }
开发者ID:heiglandreas,项目名称:callingallpapers-api_old,代码行数:27,代码来源:IcalendarRenderer.php

示例5: renderEvent

 /**
  * Render an event as vevent
  * @param VCalendar $vcalendar
  * @param Event $event
  * @param Place $place
  */
 private function renderEvent(VCalendar $vcalendar, Event $event, Place $place = null)
 {
     $vevent = $vcalendar->add('VEVENT', [], false);
     $this->addDate($event, $vevent, 'DTSTART', $event->getStart());
     $this->addDate($event, $vevent, 'DTEND', $event->getEnd());
     $properties = [];
     $properties['DTSTAMP'] = ['type' => 'DATE-TIME', 'value' => Utility::getNow()];
     $properties['UID'] = ['type' => 'UNKNOWN', 'value' => $event->getUid()];
     $properties['DESCRIPTION'] = ['type' => 'UNKNOWN', 'value' => $event->getDescription()];
     $properties['SUMMARY'] = ['type' => 'UNKNOWN', 'value' => $event->getName()];
     if ($place) {
         $properties['LOCATION'] = ['type' => 'UNKNOWN', 'value' => $place->getName()];
         $properties['GEO'] = ['type' => 'UNKNOWN', 'value' => $place->getLocation()->getLatitude() . ';' . $place->getLocation()->getLongitude()];
     }
     $allProperties = array_merge($properties, $event->getExtra());
     foreach ($allProperties as $key => $val) {
         $prop = $vevent->add($key, $val['value']);
         if ($val['type'] === 'DATE') {
             $prop['VALUE'] = $val['type'];
         }
     }
 }
开发者ID:Theodia,项目名称:theodia.org,代码行数:28,代码来源:CalendarRenderer.php

示例6: listAction

 public function listAction()
 {
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $result = $em->getRepository('Phpug\\Entity\\Cache')->findBy(array('type' => 'event'));
     $calendar = new VObject\Component\VCalendar();
     $affectedUGs = $this->findGroupsWithinRangeAndDistance();
     foreach ($result as $cal) {
         if (!$cal->getGRoup()) {
             continue;
         }
         if ($affectedUGs && !in_array($cal->getGroup()->getShortname(), $affectedUGs)) {
             continue;
         }
         try {
             $ical = VObject\Reader::read($cal->getCache());
             foreach ($ical->children as $event) {
                 if (!$event instanceof VObject\Component\VEvent) {
                     continue;
                 }
                 $result = $event->validate(VObject\Node::REPAIR);
                 if ($result) {
                     error_log(print_r($result, true));
                     continue;
                 }
                 $event->SUMMARY = '[' . $cal->getGroup()->getName() . '] ' . $event->SUMMARY;
                 $calendar->add($event);
             }
         } catch (\Exception $e) {
         }
     }
     $viewModel = $this->getViewModel();
     if ($viewModel instanceof ViewModel) {
         $viewModel->setVariable('location', $this->params()->fromQuery('latitude', 0) . ' ' . $this->params()->fromQuery('longitude', 0));
         $viewModel->setVariable('latitude', $this->params()->fromQuery('latitude', 0));
         $viewModel->setVariable('longitude', $this->params()->fromQuery('longitude', 0));
         $viewModel->setVariable('distance', $this->params()->fromQuery('distance', 100));
     }
     return $viewModel->setVariable('calendar', new \Phpug\Wrapper\SabreVCalendarWrapper($calendar));
 }
开发者ID:brainexe,项目名称:php.ug,代码行数:39,代码来源:CalendarController.php

示例7: fire

 public function fire($job, $data)
 {
     // Get the staff member
     $staff = StaffModel::find($data['staff']);
     // Set the calendar we're using
     $calendarName = str_replace(' ', '', $staff->user->name) . '.ics';
     // Get the calendar
     $calendar = new VCalendar();
     // Get a subset of the staff member's appointments
     $series = $staff->appointments->filter(function ($a) {
         // Get 14 days prior
         $targetDate = Date::now()->subDays(14)->startOfDay();
         return $a->start >= $targetDate;
     });
     foreach ($series as $a) {
         // Create a new event
         $event = [];
         // Set the summary
         $event['SUMMARY'] = $a->service->isLesson() ? "{$a->userAppointments->first()->user->name} ({$a->service->name})" : $a->service->name;
         // Set the start time and end time
         $event['DTSTART'] = $a->start;
         $event['DTEND'] = $a->end;
         if ($a->location) {
             $event['LOCATION'] = $a->location->present()->name;
         }
         if (!empty($a->notes)) {
             $event['DESCRIPTION'] = $a->notes;
         }
         // Add the event to the calendar
         $calendar->add('VEVENT', $event);
     }
     // Write the new output to the file
     File::put(App::make('path.public') . "/calendars/{$calendarName}", $calendar->serialize());
     // Delete the job from the queue
     $job->delete();
 }
开发者ID:kleitz,项目名称:bjga-scheduler,代码行数:36,代码来源:CalendarService.php

示例8: testCreateDatePropertyThroughAdd

 /**
  * This issue was discovered on the sabredav mailing list.
  */
 function testCreateDatePropertyThroughAdd()
 {
     $vcal = new VCalendar();
     $vevent = $vcal->add('VEVENT');
     $dtstart = $vevent->add('DTSTART', new \DateTime('2014-03-07'), ['VALUE' => 'DATE']);
     $this->assertEquals("DTSTART;VALUE=DATE:20140307\r\n", $dtstart->serialize());
 }
开发者ID:linagora,项目名称:sabre-vobject,代码行数:10,代码来源:DateTimeTest.php

示例9: export

 /**
  * Export events to iCalendar format
  *
  * @param  array   Events as array
  * @param  string  VCalendar method to advertise
  * @param  boolean Directly send data to stdout instead of returning
  * @param  callable Callback function to fetch attachment contents, false if no attachment export
  * @param  boolean Add VTIMEZONE block with timezone definitions for the included events
  * @return string  Events in iCalendar format (http://tools.ietf.org/html/rfc5545)
  */
 public function export($objects, $method = null, $write = false, $get_attachment = false, $with_timezones = true)
 {
     $this->method = $method;
     // encapsulate in VCALENDAR container
     $vcal = new VObject\Component\VCalendar();
     $vcal->VERSION = '2.0';
     $vcal->PRODID = $this->prodid;
     $vcal->CALSCALE = 'GREGORIAN';
     if (!empty($method)) {
         $vcal->METHOD = $method;
     }
     // write vcalendar header
     if ($write) {
         echo preg_replace('/END:VCALENDAR[\\r\\n]*$/m', '', $vcal->serialize());
     }
     foreach ($objects as $object) {
         $this->_to_ical($object, !$write ? $vcal : false, $get_attachment);
     }
     // include timezone information
     if ($with_timezones || !empty($method)) {
         foreach ($this->vtimezones as $tzid => $range) {
             $vt = self::get_vtimezone($tzid, $range[0], $range[1]);
             if (empty($vt)) {
                 continue;
                 // no timezone information found
             }
             if ($write) {
                 echo $vt->serialize();
             } else {
                 $vcal->add($vt);
             }
         }
     }
     if ($write) {
         echo "END:VCALENDAR\r\n";
         return true;
     } else {
         return $vcal->serialize();
     }
 }
开发者ID:Fneufneu,项目名称:libcalendaring,代码行数:50,代码来源:libvcalendar.php

示例10: testGetDateInterval

 function testGetDateInterval()
 {
     $vcal = new VCalendar();
     $event = $vcal->add('VEVENT', array('DURATION' => array('PT1H')));
     $this->assertEquals(new \DateInterval('PT1H'), $event->{'DURATION'}->getDateInterval());
 }
开发者ID:bodun,项目名称:jorani,代码行数:6,代码来源:DurationTest.php

示例11: testRemoveByObj

 function testRemoveByObj()
 {
     $comp = new VCalendar(array(), false);
     $comp->add('prop1', 'val1');
     $prop = $comp->add('prop2', 'val2');
     $comp->remove($prop);
     $this->assertFalse(isset($comp->prop2));
     $this->assertTrue(isset($comp->prop1));
 }
开发者ID:bodun,项目名称:jorani,代码行数:9,代码来源:ComponentTest.php

示例12: testSetSubParts

 function testSetSubParts()
 {
     $vcal = new VCalendar();
     $recur = $vcal->add('RRULE', array('FREQ' => 'DAILY', 'BYDAY' => 'mo,tu', 'BYMONTH' => array(0, 1)));
     $this->assertEquals(array('FREQ' => 'DAILY', 'BYDAY' => array('MO', 'TU'), 'BYMONTH' => array(0, 1)), $recur->getParts());
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:6,代码来源:RecurTest.php

示例13: testArrayAccessUnsetInt

 /**
  * ElementList should reject this.
  *
  * @expectedException \LogicException
  */
 public function testArrayAccessUnsetInt()
 {
     $calendar = new VCalendar();
     $property = $calendar->createProperty("X-PROP", null);
     $calendar->add($property);
     unset($calendar->{'X-PROP'}[0]);
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:12,代码来源:PropertyTest.php

示例14: elseif

        } elseif ($game[3] == 'Quarter-Finals' && $param == 'ALLQ') {
            $copygame = true;
        } elseif ($game[3] == 'Half-Finals' && $param == 'ALLH') {
            $copygame = true;
        }
        /* elseif ($game[3] == 'Quarter-Finals' || $game[3] == 'Half-Finals' || $game[3] == 'Final') { // for now everyone gets the quarter/half/Final
               $copygame = true;
           }*/
    }
    if ($copygame) {
        array_push($outgames, $game);
    }
}
// format the calendar
$vcalendar = new VObject\Component\VCalendar();
$vcalendar->add('X-WR-CALNAME', 'EURO 2016 Schedule ' . $param_in);
$vcalendar->add('X-WR-CALDESC', 'EURO 2016 Schedule ' . $param_in . "\nbrought to you by http://kralo.github.io/euro2016-calendar-ics-exporter/");
foreach ($outgames as $game) {
    $vev = $vcalendar->add('VEVENT', ['UID' => 'euro2016_game' . $game[0]]);
    // Summary and description; also resources
    if ($game[6] != 'Z' && sizeof($game[6]) == 1) {
        $involved = $game[6][0];
    } else {
        $involved = $game[4];
    }
    $involved .= ' - ';
    if ($game[7] != 'Z' && sizeof($game[7]) == 1) {
        $involved .= $game[7][0];
    } else {
        $involved .= $game[5];
    }
开发者ID:kralo,项目名称:euro2016-calendar-ics-exporter,代码行数:31,代码来源:makecal.php

示例15: generateIcal

 /**
  *  Generate ical file content
  *
  * @param $who             user ID
  * @param $who_group       group ID
  * @param $limititemtype   itemtype only display this itemtype (default '')
  *
  * @return icalendar string
  **/
 static function generateIcal($who, $who_group, $limititemtype = '')
 {
     global $CFG_GLPI;
     if ($who === 0 && $who_group === 0) {
         return false;
     }
     if (!empty($CFG_GLPI["version"])) {
         $unique_id = "GLPI-Planning-" . trim($CFG_GLPI["version"]);
     } else {
         $unique_id = "GLPI-Planning-UnknownVersion";
     }
     // create vcalendar
     $vcalendar = new VObject\Component\VCalendar();
     // $xprops = array( "X-LIC-LOCATION" => $tz );
     // iCalUtilityFunctions::createTimezone( $v, $tz, $xprops );
     $interv = array();
     $begin = time() - MONTH_TIMESTAMP * 12;
     $end = time() + MONTH_TIMESTAMP * 12;
     $begin = date("Y-m-d H:i:s", $begin);
     $end = date("Y-m-d H:i:s", $end);
     $params = array('genical' => true, 'who' => $who, 'who_group' => $who_group, 'whogroup' => $who_group, 'begin' => $begin, 'end' => $end);
     $interv = array();
     if (empty($limititemtype)) {
         foreach ($CFG_GLPI['planning_types'] as $itemtype) {
             $interv = array_merge($interv, $itemtype::populatePlanning($params));
         }
     } else {
         $interv = $limititemtype::populatePlanning($params);
     }
     if (count($interv) > 0) {
         foreach ($interv as $key => $val) {
             if (isset($val['itemtype'])) {
                 if (isset($val[getForeignKeyFieldForItemType($val['itemtype'])])) {
                     $uid = $val['itemtype'] . "#" . $val[getForeignKeyFieldForItemType($val['itemtype'])];
                 } else {
                     $uid = "Other#" . $key;
                 }
             } else {
                 $uid = "Other#" . $key;
             }
             $vevent['UID'] = $uid;
             $vevent['DTSTART'] = new \DateTime($val["begin"]);
             $vevent['DTEND'] = new \DateTime($val["end"]);
             if (isset($val["tickets_id"])) {
                 $summary = sprintf(__('Ticket #%1$s %2$s'), $val["tickets_id"], $val["name"]);
             } else {
                 if (isset($val["name"])) {
                     $summary = $val["name"];
                 }
             }
             $vevent['SUMMARY'] = $summary;
             if (isset($val["content"])) {
                 $description = $val["content"];
                 // be sure to replace nl by \r\n
                 $description = preg_replace("/<br( [^>]*)?" . ">/i", "\r\n", $description);
                 $description = Html::clean($description);
             } else {
                 if (isset($val["name"])) {
                     $description = $val["name"];
                     // be sure to replace nl by \r\n
                     $description = preg_replace("/<br( [^>]*)?" . ">/i", "\r\n", $description);
                     $description = Html::clean($description);
                 }
             }
             $vevent['DESCRIPTION'] = $description;
             if (isset($val["url"])) {
                 $vevent['URL'] = $val["url"];
             }
             $vcalendar->add('VEVENT', $vevent);
         }
     }
     $output = $vcalendar->serialize();
     $filename = date('YmdHis') . '.ics';
     @Header("Content-Disposition: attachment; filename=\"{$filename}\"");
     @Header("Content-Length: " . Toolbox::strlen($output));
     @Header("Connection: close");
     @Header("content-type: text/calendar; charset=utf-8");
     echo $output;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:88,代码来源:planning.class.php


注:本文中的Sabre\VObject\Component\VCalendar::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。