本文整理汇总了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');
}
}
}
示例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);
}
示例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');
}
}
}