當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OC_Calendar_Object::isrepeating方法代碼示例

本文整理匯總了PHP中OC_Calendar_Object::isrepeating方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Calendar_Object::isrepeating方法的具體用法?PHP OC_Calendar_Object::isrepeating怎麽用?PHP OC_Calendar_Object::isrepeating使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC_Calendar_Object的用法示例。


在下文中一共展示了OC_Calendar_Object::isrepeating方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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);
     }
 }
開發者ID:yheric455042,項目名稱:owncloud82,代碼行數:82,代碼來源:app.php

示例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($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;
 }
開發者ID:blablubli,項目名稱:owncloudapps,代碼行數:56,代碼來源:app.php


注:本文中的OC_Calendar_Object::isrepeating方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。