本文整理汇总了PHP中OC_Calendar_Object::generateStartEndDate方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Object::generateStartEndDate方法的具体用法?PHP OC_Calendar_Object::generateStartEndDate怎么用?PHP OC_Calendar_Object::generateStartEndDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Object
的用法示例。
在下文中一共展示了OC_Calendar_Object::generateStartEndDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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;
}