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


PHP Kronolith::getCalendar方法代碼示例

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


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

示例1: download

 /**
  * @throws Kronolith_Exception
  */
 public function download(Horde_Variables $vars)
 {
     global $display_calendars, $injector;
     switch ($vars->actionID) {
         case 'download_file':
             $source = Horde_Util::getFormData('source');
             $key = Horde_Util::getFormData('key');
             $filename = Horde_Util::getFormData('file');
             $type = Horde_Util::getFormData('type');
             list($driver_type, $calendar) = explode('|', $source);
             if ($driver_type == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) {
                 $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
                 return false;
             }
             try {
                 $driver = Kronolith::getDriver($driver_type, $calendar);
             } catch (Exception $e) {
                 $GLOBALS['notification']->push($e, 'horde.error');
                 return false;
             }
             $event = $driver->getEvent($key);
             /* Check permissions. */
             if (!$event->hasPermission(Horde_Perms::READ)) {
                 throw new Kronolith_Exception(_("You do not have permission to view this event."));
             }
             try {
                 $data = $event->vfsInit()->read(Kronolith::VFS_PATH . '/' . $event->getVfsUid(), $filename);
             } catch (Horde_Vfs_Exception $e) {
                 Horde::log($e, 'ERR');
                 throw new Kronolith_Exception(sprintf(_("Access denied to %s"), $filename));
             }
             try {
                 return array('data' => $data, 'name' => $vars->file, 'type' => $type);
             } catch (Horde_Vfs_Exception $e) {
                 Horde::log($e, 'ERR');
                 throw new Kronolith_Exception(sprintf(_("Access denied to %s"), $vars->file));
             }
         case 'export':
             if ($vars->all_events) {
                 $end = $start = null;
             } else {
                 $start = new Horde_Date($vars->start_year, $vars->start_month, $vars->start_day);
                 $end = new Horde_Date($vars->end_year, $vars->end_month, $vars->end_day);
             }
             $calendars = $vars->get('exportCal', $display_calendars);
             if (!is_array($calendars)) {
                 $calendars = array($calendars);
             }
             $events = array();
             foreach ($calendars as $calendar) {
                 list($type, $cal) = explode('_', $calendar, 2);
                 $kronolith_driver = Kronolith::getDriver($type, $cal);
                 $calendarObject = Kronolith::getCalendar($kronolith_driver);
                 if (!$calendarObject || !$calendarObject->hasPermission(Horde_Perms::READ)) {
                     throw new Horde_Exception_PermissionDenied();
                 }
                 $events[$calendar] = $kronolith_driver->listEvents($start, $end, array('cover_dates' => false, 'hide_exceptions' => $vars->exportID == Horde_Data::EXPORT_ICALENDAR));
             }
             switch ($vars->exportID) {
                 case Horde_Data::EXPORT_CSV:
                     $data = array();
                     foreach ($events as $calevents) {
                         foreach ($calevents as $dayevents) {
                             foreach ($dayevents as $event) {
                                 $row = array('alarm' => $event->alarm, 'description' => $event->description, 'end_date' => $event->end->format('Y-m-d'), 'end_time' => $event->end->format('H:i:s'), 'location' => $event->location, 'private' => intval($event->private), 'recur_type' => null, 'recur_end_date' => null, 'recur_interval' => null, 'recur_data' => null, 'start_date' => $event->start->format('Y-m-d'), 'start_time' => $event->start->format('H:i:s'), 'tags' => implode(', ', $event->tags), 'title' => $event->getTitle());
                                 if ($event->recurs()) {
                                     $row['recur_type'] = $event->recurrence->getRecurType();
                                     if ($event->recurrence->hasRecurEnd()) {
                                         $row['recur_end_date'] = $event->recurrence->recurEnd->format('Y-m-d');
                                     }
                                     $row['recur_interval'] = $event->recurrence->getRecurInterval();
                                     $row['recur_data'] = $event->recurrence->recurData;
                                 }
                                 $data[] = $row;
                             }
                         }
                     }
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("events.csv"), $data, true);
                     exit;
                 case Horde_Data::EXPORT_ICALENDAR:
                     $calNames = array();
                     $iCal = new Horde_Icalendar();
                     foreach ($events as $calevents) {
                         foreach ($calevents as $dayevents) {
                             foreach ($dayevents as $event) {
                                 $calNames[Kronolith::getCalendar($event->getDriver())->name()] = true;
                                 $iCal->addComponent($event->toiCalendar($iCal));
                             }
                         }
                     }
                     $iCal->setAttribute('X-WR-CALNAME', implode(', ', array_keys($calNames)));
                     return array('data' => $iCal->exportvCalendar(), 'name' => _("events.ics"), 'type' => 'text/calendar');
             }
     }
 }
開發者ID:horde,項目名稱:horde,代碼行數:98,代碼來源:Application.php

示例2: getCalendar

 /**
  * Return an internal calendar.
  *
  * @todo Note: This returns a Kronolith_Calendar_Object object instead of a hash
  * to be consistent with other application APIs. For H6 we need to normalize
  * the APIs to always return non-objects and/or implement some mechanism to
  * mark API methods as non-RPC safe.
  *
  * @param string $id  The calendar uid (share name).
  *
  * @return Kronolith_Calendar The calendar object.
  * @since 4.2.0
  */
 public function getCalendar($id = null)
 {
     $driver = Kronolith::getDriver(null, $id);
     return Kronolith::getCalendar($driver);
 }
開發者ID:horde,項目名稱:horde,代碼行數:18,代碼來源:Api.php

示例3: download

 /**
  * @throws Kronolith_Exception
  */
 public function download(Horde_Variables $vars)
 {
     global $display_calendars, $injector;
     switch ($vars->actionID) {
         case 'export':
             if ($vars->all_events) {
                 $end = $start = null;
             } else {
                 $start = new Horde_Date($vars->start_year, $vars->start_month, $vars->start_day);
                 $end = new Horde_Date($vars->end_year, $vars->end_month, $vars->end_day);
             }
             $calendars = $vars->get('exportCal', $display_calendars);
             if (!is_array($calendars)) {
                 $calendars = array($calendars);
             }
             $events = array();
             foreach ($calendars as $calendar) {
                 list($type, $cal) = explode('_', $calendar, 2);
                 $kronolith_driver = Kronolith::getDriver($type, $cal);
                 $calendarObject = Kronolith::getCalendar($kronolith_driver);
                 if (!$calendarObject || !$calendarObject->hasPermission(Horde_Perms::READ)) {
                     throw new Horde_Exception_PermissionDenied();
                 }
                 $events[$calendar] = $kronolith_driver->listEvents($start, $end, array('cover_dates' => false, 'hide_exceptions' => $vars->exportID == Horde_Data::EXPORT_ICALENDAR));
             }
             switch ($vars->exportID) {
                 case Horde_Data::EXPORT_CSV:
                     $data = array();
                     foreach ($events as $calevents) {
                         foreach ($calevents as $dayevents) {
                             foreach ($dayevents as $event) {
                                 $row = array('alarm' => $event->alarm, 'description' => $event->description, 'end_date' => $event->end->format('Y-m-d'), 'end_time' => $event->end->format('H:i:s'), 'location' => $event->location, 'private' => intval($event->private), 'recur_type' => null, 'recur_end_date' => null, 'recur_interval' => null, 'recur_data' => null, 'start_date' => $event->start->format('Y-m-d'), 'start_time' => $event->start->format('H:i:s'), 'tags' => implode(', ', $event->tags), 'title' => $event->getTitle());
                                 if ($event->recurs()) {
                                     $row['recur_type'] = $event->recurrence->getRecurType();
                                     if ($event->recurrence->hasRecurEnd()) {
                                         $row['recur_end_date'] = $event->recurrence->recurEnd->format('Y-m-d');
                                     }
                                     $row['recur_interval'] = $event->recurrence->getRecurInterval();
                                     $row['recur_data'] = $event->recurrence->recurData;
                                 }
                                 $data[] = $row;
                             }
                         }
                     }
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("events.csv"), $data, true);
                     exit;
                 case Horde_Data::EXPORT_ICALENDAR:
                     $calNames = array();
                     $iCal = new Horde_Icalendar();
                     foreach ($events as $calevents) {
                         foreach ($calevents as $dayevents) {
                             foreach ($dayevents as $event) {
                                 $calNames[Kronolith::getCalendar($event->getDriver())->name()] = true;
                                 $iCal->addComponent($event->toiCalendar($iCal));
                             }
                         }
                     }
                     $iCal->setAttribute('X-WR-CALNAME', implode(', ', array_keys($calNames)));
                     return array('data' => $iCal->exportvCalendar(), 'name' => _("events.ics"), 'type' => 'text/calendar');
             }
     }
 }
開發者ID:DSNS-LAB,項目名稱:Dmail,代碼行數:65,代碼來源:Application.php


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