本文整理汇总了PHP中OC_Calendar_Object::getDTEndFromVEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Object::getDTEndFromVEvent方法的具体用法?PHP OC_Calendar_Object::getDTEndFromVEvent怎么用?PHP OC_Calendar_Object::getDTEndFromVEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Object
的用法示例。
在下文中一共展示了OC_Calendar_Object::getDTEndFromVEvent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateEvent
/**
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
*/
private static function generateEvent($event)
{
$object = OC_VObject::parse($event['calendardata']);
if (!$object) {
return false;
}
if ($object->VEVENT) {
$dtstart = $object->VEVENT->DTSTART;
$start_dt = $dtstart->getDateTime();
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() !== Sabre\VObject\Property\DateTime::DATE) {
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt->setTimezone(new DateTimeZone('UTC'));
$object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre\VObject\Property\DateTime::UTC);
$object->VEVENT->setDateTime('DTEND', $end_dt, Sabre\VObject\Property\DateTime::UTC);
}
return $object->VEVENT->serialize();
}
if ($object->VTODO) {
return $object->VTODO->serialize();
}
if ($object->VJOURNAL) {
return $object->VJOURNAL->serialize();
}
return '';
}
示例2: generateEvent
/**
* @brief generates the VEVENT/VTODO/VJOURNAL with UTC dates
* @param array $event
* @return string
*/
private static function generateEvent($event)
{
$object = OC_VObject::parse($event['calendardata']);
if (!$object) {
return false;
}
$sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object);
if (OC_Calendar_Object::getowner($event['id']) !== OCP\User::getUser()) {
if (!($sharedAccessClassPermissions & OCP\PERMISSION_READ)) {
return '';
}
}
$object = OC_Calendar_Object::cleanByAccessClass($event['id'], $object);
if ($object->VEVENT) {
$dtstart = $object->VEVENT->DTSTART;
$start_dt = $dtstart->getDateTime();
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() !== Sabre\VObject\Property\DateTime::DATE) {
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt->setTimezone(new DateTimeZone('UTC'));
$object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre\VObject\Property\DateTime::UTC);
$object->VEVENT->setDateTime('DTEND', $end_dt, Sabre\VObject\Property\DateTime::UTC);
}
return $object->VEVENT->serialize();
}
if ($object->VTODO) {
return $object->VTODO->serialize();
}
if ($object->VJOURNAL) {
return $object->VJOURNAL->serialize();
}
return '';
}
示例3: generateEvent
/**
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
*/
private static function generateEvent($event)
{
$object = OC_VObject::parse($event['calendardata']);
$dtstart = $object->VEVENT->DTSTART;
$start_dt = $dtstart->getDateTime();
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() !== Sabre_VObject_Element_DateTime::DATE) {
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt->setTimezone(new DateTimeZone('UTC'));
$object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre_VObject_Property_DateTime::UTC);
$object->VEVENT->setDateTime('DTEND', $end_dt, Sabre_VObject_Property_DateTime::UTC);
}
return $object->VEVENT->serialize();
}
示例4: search
function search($query)
{
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
//return false;
}
$results = array();
$searchquery = array();
if (substr_count($query, ' ') > 0) {
$searchquery = explode(' ', $query);
} else {
$searchquery[] = $query;
}
$user_timezone = OC_Calendar_App::getTimezone();
$l = new OC_l10n('calendar');
foreach ($calendars as $calendar) {
$objects = OC_Calendar_Object::all($calendar['id']);
foreach ($objects as $object) {
if ($object['objecttype'] != 'VEVENT') {
continue;
}
if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
$calendardata = OC_VObject::parse($object['calendardata']);
$vevent = $calendardata->VEVENT;
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$start_dt = $dtstart->getDateTime();
$start_dt->setTimezone(new DateTimeZone($user_timezone));
$end_dt = $dtend->getDateTime();
$end_dt->setTimezone(new DateTimeZone($user_timezone));
if ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE) {
$end_dt->modify('-1 sec');
if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
} else {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
}
} else {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
$link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
$results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
//$name,$text,$link,$type
}
}
}
return $results;
}
示例5: __construct
/**
* Constructor
*
* @param array $data
* @return \OCA\Calendar\Search\Event
*/
public function __construct(array $data = null)
{
// set default properties
$this->id = $data['id'];
$this->name = $data['summary'];
$this->link = \OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($data['id']);
// do calendar-specific setup
$l = new \OC_l10n('calendar');
$calendar_data = \Sabre\VObject\Reader::read($data['calendardata']);
$vevent = $calendar_data->VEVENT;
// get start time
$dtstart = $vevent->DTSTART;
$start_dt = $dtstart->getDateTime();
$start_dt->setTimezone($this->getUserTimezone());
$this->start_time = $start_dt->format('r');
// get end time
$dtend = \OC_Calendar_Object::getDTEndFromVEvent($vevent);
$end_dt = $dtend->getDateTime();
$end_dt->setTimezone($this->getUserTimezone());
$this->end_time = $end_dt->format('r');
// create text description
if (!$dtstart->hasTime()) {
$end_dt->modify('-1 sec');
if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
} else {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
}
} else {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
// set last modified time
$this->modified = date('r', $data['lastmodified']);
// set repeating property
$this->repeating = (bool) $data['repeating'];
}
示例6: getDateRange
/**
* Return the start time and end time of a calendar object in Unix time
*
* @param array $calendarObject must contain a VEVENT
* @return array [start, end] in Unix time
*/
private function getDateRange($calendarObject)
{
$calendarData = \OC_VObject::parse($calendarObject['calendardata']);
// set start
$start = $calendarData->VEVENT->DTSTART->getDateTime();
$start->setTimezone(Event::getUserTimezone());
// set end
$end = \OC_Calendar_Object::getDTEndFromVEvent($calendarData->VEVENT)->getDateTime();
$end->setTimezone(Event::getUserTimezone());
// return
return array($start->getTimestamp(), $end->getTimestamp());
}
示例7: generateEventOutput
/**
* @brief generates the output for an event which will be readable for our js
* @param (mixed) $event - event object / array
* @param (int) $start - DateTime object of start
* @param (int) $end - DateTime object of end
* @return (array) $output - readable output
*/
public static function generateEventOutput(array $event, $start, $end)
{
if (!isset($event['calendardata']) && !isset($event['vevent'])) {
return false;
}
if (!isset($event['calendardata']) && isset($event['vevent'])) {
$event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR";
}
try {
$object = OC_VObject::parse($event['calendardata']);
if (!$object) {
\OCP\Util::writeLog('calendar', __METHOD__ . ' Error parsing event: ' . print_r($event, true), \OCP\Util::DEBUG);
return array();
}
$output = array();
if ($object->name === 'VEVENT') {
$vevent = $object;
} elseif (isset($object->VEVENT)) {
$vevent = $object->VEVENT;
} else {
\OCP\Util::writeLog('calendar', __METHOD__ . ' Object contains not event: ' . print_r($event, true), \OCP\Util::DEBUG);
return $output;
}
$id = $event['id'];
if (OC_Calendar_Object::getowner($id) !== OCP\USER::getUser()) {
// do not show events with private or unknown access class
if (isset($vevent->CLASS) && ($vevent->CLASS->value === 'PRIVATE' || $vevent->CLASS->value === '')) {
return $output;
}
$object = OC_Calendar_Object::cleanByAccessClass($id, $object);
}
$allday = $vevent->DTSTART->getDateType() == Sabre\VObject\Property\DateTime::DATE ? true : false;
$last_modified = @$vevent->__get('LAST-MODIFIED');
$lastmodified = $last_modified ? $last_modified->getDateTime()->format('U') : 0;
$staticoutput = array('id' => (int) $event['id'], 'title' => !is_null($vevent->SUMMARY) && $vevent->SUMMARY->value != '' ? strtr($vevent->SUMMARY->value, array('\\,' => ',', '\\;' => ';')) : self::$l10n->t('unnamed'), 'description' => isset($vevent->DESCRIPTION) ? strtr($vevent->DESCRIPTION->value, array('\\,' => ',', '\\;' => ';')) : '', 'lastmodified' => $lastmodified, 'allDay' => $allday);
if (OC_Calendar_Object::isrepeating($id) && OC_Calendar_Repeat::is_cached_inperiod($event['id'], $start, $end)) {
$cachedinperiod = OC_Calendar_Repeat::get_inperiod($id, $start, $end);
foreach ($cachedinperiod as $cachedevent) {
$dynamicoutput = array();
if ($allday) {
$start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
$end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
$dynamicoutput['start'] = $start_dt->format('Y-m-d');
$dynamicoutput['end'] = $end_dt->format('Y-m-d');
} else {
$start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
$end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
$start_dt->setTimezone(new DateTimeZone(self::$tz));
$end_dt->setTimezone(new DateTimeZone(self::$tz));
$dynamicoutput['start'] = $start_dt->format('Y-m-d H:i:s');
$dynamicoutput['end'] = $end_dt->format('Y-m-d H:i:s');
}
$output[] = array_merge($staticoutput, $dynamicoutput);
}
} else {
if (OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1) {
$object->expand($start, $end);
}
foreach ($object->getComponents() as $singleevent) {
if (!$singleevent instanceof Sabre\VObject\Component\VEvent) {
continue;
}
$dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz);
$output[] = array_merge($staticoutput, $dynamicoutput);
}
}
return $output;
} catch (Exception $e) {
$uid = 'unknown';
if (isset($event['uri'])) {
$uid = $event['uri'];
}
\OCP\Util::writeLog('calendar', 'Event (' . $uid . ') contains invalid data: ' . $e->getMessage(), \OCP\Util::WARN);
}
}
示例8: DateInterval
OCP\JSON::checkLoggedIn();
$id = $_POST['id'];
$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
if ($access != 'owner' && $access != 'rw') {
OCP\JSON::error(array('message' => 'permission denied'));
exit;
}
$vcalendar = OC_Calendar_App::getVCalendar($id, false, false);
$vevent = $vcalendar->VEVENT;
$allday = $_POST['allDay'];
$delta = new DateInterval('P0D');
$delta->d = $_POST['dayDelta'];
$delta->i = $_POST['minuteDelta'];
OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$start_type = $dtstart->getDateType();
$end_type = $dtend->getDateType();
if ($allday && $start_type != Sabre_VObject_Property_DateTime::DATE) {
$start_type = $end_type = Sabre_VObject_Property_DateTime::DATE;
$dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type);
}
if (!$allday && $start_type == Sabre_VObject_Property_DateTime::DATE) {
$start_type = $end_type = Sabre_VObject_Property_DateTime::LOCALTZ;
}
$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type);
$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
unset($vevent->DURATION);
$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC);
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
示例9: import
public function import()
{
if (!$this->isValid()) {
return false;
}
$numofcomponents = count($this->calobject->getComponents());
if ($this->overwrite) {
foreach (OC_Calendar_Object::all($this->id) as $obj) {
OC_Calendar_Object::delete($obj['id']);
}
}
foreach ($this->calobject->getComponents() as $object) {
if (!$object instanceof Sabre\VObject\Component\VEvent && !$object instanceof Sabre\VObject\Component\VJournal && !$object instanceof Sabre\VObject\Component\VTodo) {
continue;
}
if (!is_null($object->DTSTART)) {
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object);
if ($object->DTEND) {
$object->DTEND->setDateTime($dtend->getDateTime(), $object->DTSTART->getDateType());
}
}
$vcalendar = $this->createVCalendar($object->serialize());
$insertid = OC_Calendar_Object::add($this->id, $vcalendar);
$this->abscount++;
if ($this->isDuplicate($insertid)) {
OC_Calendar_Object::delete($insertid);
} else {
$this->count++;
}
$this->updateProgress(intval($this->abscount / $numofcomponents * 100));
}
OC_Cache::remove($this->progresskey);
return true;
}
示例10: generate
/**
* @brief generates the cache the first time
* @param (int) id - id of the event
* @return (bool)
*/
public static function generate($id)
{
$event = OC_Calendar_Object::find($id);
if ($event['repeating'] == 0) {
return false;
}
$object = OC_VObject::parse($event['calendardata']);
$start = new DateTime('01-01-' . date('Y') . ' 00:00:00', new DateTimeZone('UTC'));
$start->modify('-5 years');
$end = new DateTime('31-12-' . date('Y') . ' 23:59:59', new DateTimeZone('UTC'));
$end->modify('+5 years');
$object->expand($start, $end);
foreach ($object->getComponents() as $vevent) {
if (!$vevent instanceof Sabre\VObject\Component\VEvent) {
continue;
}
$startenddate = OC_Calendar_Object::generateStartEndDate($vevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($vevent), $vevent->DTSTART->getDateType() == Sabre\VObject\Property\DateTime::DATE ? true : false, 'UTC');
$stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_repeat` (`eventid`,`calid`,`startdate`,`enddate`) VALUES(?,?,?,?)');
$stmt->execute(array($id, OC_Calendar_Object::getCalendarid($id), $startenddate['start'], $startenddate['end']));
}
return true;
}
示例11: generateEventOutput
public static function generateEventOutput($event, $start, $end)
{
$output = array();
if (isset($event['calendardata'])) {
$object = OC_VObject::parse($event['calendardata']);
$vevent = $object->VEVENT;
} else {
$vevent = $event['vevent'];
}
$last_modified = @$vevent->__get('LAST-MODIFIED');
$lastmodified = $last_modified ? $last_modified->getDateTime()->format('U') : 0;
$output = array('id' => (int) $event['id'], 'title' => $event['summary'] != NULL || $event['summary'] != '' ? $event['summary'] : self::$l10n->t('unnamed'), 'description' => isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '', 'lastmodified' => $lastmodified);
$dtstart = $vevent->DTSTART;
$start_dt = $dtstart->getDateTime();
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE) {
$output['allDay'] = true;
} else {
$output['allDay'] = false;
$start_dt->setTimezone(new DateTimeZone(self::$tz));
$end_dt->setTimezone(new DateTimeZone(self::$tz));
}
// Handle exceptions to recurring events
$exceptionDateObjects = $vevent->select('EXDATE');
$exceptionDateMap = array();
foreach ($exceptionDateObjects as $exceptionObject) {
foreach ($exceptionObject->getDateTimes() as $datetime) {
$ts = $datetime->getTimestamp();
$exceptionDateMap[idate('Y', $ts)][idate('m', $ts)][idate('d', $ts)] = true;
}
}
$return = array();
if ($event['repeating'] == 1) {
$duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
$r = new When();
$r->recur($start_dt)->rrule((string) $vevent->RRULE);
/*$r = new iCal_Repeat_Generator(array('RECUR' => $start_dt,
* 'RRULE' => (string)$vevent->RRULE
* 'RDATE' => (string)$vevent->RDATE
* 'EXRULE' => (string)$vevent->EXRULE
* 'EXDATE' => (string)$vevent->EXDATE));*/
while ($result = $r->next()) {
if ($result < $start) {
continue;
}
if ($result > $end) {
break;
}
// Check for exceptions to recurring events
$ts = $result->getTimestamp();
if (isset($exceptionDateMap[idate('Y', $ts)][idate('m', $ts)][idate('d', $ts)])) {
continue;
}
unset($ts);
if ($output['allDay'] == true) {
$output['start'] = $result->format('Y-m-d');
$output['end'] = date('Y-m-d', $result->format('U') + --$duration);
} else {
$output['start'] = $result->format('Y-m-d H:i:s');
$output['end'] = date('Y-m-d H:i:s', $result->format('U') + $result->format('Z') + $duration);
}
$return[] = $output;
}
} else {
if ($output['allDay'] == true) {
$output['start'] = $start_dt->format('Y-m-d');
$end_dt->modify('-1 sec');
$output['end'] = $end_dt->format('Y-m-d');
} else {
$output['start'] = $start_dt->format('Y-m-d H:i:s');
$output['end'] = $end_dt->format('Y-m-d H:i:s');
}
$return[] = $output;
}
return $return;
}
示例12: generateEventOutput
/**
* @brief generates the output for an event which will be readable for our js
* @param (mixed) $event - event object / array
* @param (int) $start - DateTime object of start
* @param (int) $end - DateTime object of end
* @return (array) $output - readable output
*/
public static function generateEventOutput($event, $start, $end)
{
if (!isset($event['calendardata']) && !isset($event['vevent'])) {
return false;
}
if (!isset($event['calendardata']) && isset($event['vevent'])) {
$event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR";
}
$object = OC_VObject::parse($event['calendardata']);
$vevent = $object->VEVENT;
$return = array();
$id = $event['id'];
$allday = $vevent->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE ? true : false;
$last_modified = @$vevent->__get('LAST-MODIFIED');
$lastmodified = $last_modified ? $last_modified->getDateTime()->format('U') : 0;
$staticoutput = array('id' => (int) $event['id'], 'title' => $event['summary'] != NULL || $event['summary'] != '' ? $event['summary'] : self::$l10n->t('unnamed'), 'description' => isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '', 'lastmodified' => $lastmodified, 'allDay' => $allday);
if (OC_Calendar_Object::isrepeating($id) && OC_Calendar_Repeat::is_cached_inperiod($event['id'], $start, $end)) {
$cachedinperiod = OC_Calendar_Repeat::get_inperiod($id, $start, $end);
foreach ($cachedinperiod as $cachedevent) {
$dynamicoutput = array();
if ($allday) {
$start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
$end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
$dynamicoutput['start'] = $start_dt->format('Y-m-d');
$dynamicoutput['end'] = $end_dt->format('Y-m-d');
} else {
$start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
$end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
$start_dt->setTimezone(new DateTimeZone(self::$tz));
$end_dt->setTimezone(new DateTimeZone(self::$tz));
$dynamicoutput['start'] = $start_dt->format('Y-m-d H:i:s');
$dynamicoutput['end'] = $end_dt->format('Y-m-d H:i:s');
}
$return[] = array_merge($staticoutput, $dynamicoutput);
}
} else {
if (OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1) {
$object->expand($start, $end);
}
foreach ($object->getComponents() as $singleevent) {
if (!$singleevent instanceof Sabre_VObject_Component_VEvent) {
continue;
}
$dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz);
$return[] = array_merge($staticoutput, $dynamicoutput);
}
}
return $return;
}