本文整理汇总了PHP中Kronolith::listEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::listEvents方法的具体用法?PHP Kronolith::listEvents怎么用?PHP Kronolith::listEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::listEvents方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param Horde_Date $date The day for this view
* @param array $events An array of Kronolith_Event objects
*
* @return Kronolith_View_Day
*/
public function __construct(Horde_Date $date, array $events = null)
{
parent::__construct($date->month, $date->mday, $date->year);
$this->sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side');
if ($this->sidebyside) {
$allCalendars = Kronolith::listInternalCalendars();
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $cid) {
$this->_currentCalendars[$cid] = $allCalendars[$cid];
$this->all_day_events[$cid] = array();
}
} else {
$this->_currentCalendars = array(0);
}
if ($events === null) {
try {
$events = Kronolith::listEvents($this, new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->mday)));
$this->events = array_shift($events);
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$this->events = array();
}
} else {
$this->events = $events;
}
if (!is_array($this->events)) {
$this->events = array();
}
}
示例2: __construct
/**
*
* @param Horde_Date $date
*
* @return Kronolith_View_Year
*/
public function __construct(Horde_Date $date)
{
$this->year = $date->year;
$startDate = new Horde_Date(array('year' => $this->year, 'month' => 1, 'mday' => 1));
$endDate = new Horde_Date(array('year' => $this->year, 'month' => 12, 'mday' => 31));
try {
$this->_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$this->_events = array();
}
if (!is_array($this->_events)) {
$this->_events = array();
}
}
示例3: __construct
public function __construct(Horde_Date $date)
{
$week = $date->weekOfYear();
$year = $date->year;
if (!$GLOBALS['prefs']->getValue('week_start_monday') && $date->dayOfWeek() == Horde_Date::DATE_SUNDAY) {
++$week;
}
if ($week > 51 && $date->month == 1) {
--$year;
} elseif ($week == 1 && $date->month == 12) {
++$year;
}
$this->year = $year;
$this->week = $week;
$day = Horde_Date_Utils::firstDayOfWeek($week, $year);
if (!isset($this->startDay)) {
if ($GLOBALS['prefs']->getValue('week_start_monday')) {
$this->startDay = Horde_Date::DATE_MONDAY;
$this->endDay = Horde_Date::DATE_SUNDAY + 7;
} else {
$day->mday--;
$this->startDay = Horde_Date::DATE_SUNDAY;
$this->endDay = Horde_Date::DATE_SATURDAY;
}
}
$this->startDate = new Horde_Date($day);
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
$this->days[$i] = new Kronolith_View_Day($day, array());
$day->mday++;
}
$endDate = new Horde_Date($day);
try {
$allevents = Kronolith::listEvents($this->startDate, $endDate);
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$allevents = array();
}
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
$date_stamp = $this->days[$i]->dateString();
$this->days[$i]->events = isset($allevents[$date_stamp]) ? $allevents[$date_stamp] : array();
}
$this->sidebyside = $this->days[$this->startDay]->sidebyside;
$this->_currentCalendars = $this->days[$this->startDay]->currentCalendars;
$this->slotsPerHour = $this->days[$this->startDay]->slotsPerHour;
$this->slotsPerDay = $this->days[$this->startDay]->slotsPerDay;
$this->slotLength = $this->days[$this->startDay]->slotLength;
}
示例4: __construct
/**
*
* @global Horde_Prefs $prefs
* @param Horde_Date $date
*
* @return Kronolith_View_Month
*/
public function __construct(Horde_Date $date)
{
global $prefs;
$this->month = $date->month;
$this->year = $date->year;
// Need to calculate the start and length of the view.
$this->date = new Horde_Date($date);
$this->date->mday = 1;
$this->_startday = $this->date->dayOfWeek();
if (!$prefs->getValue('week_start_monday')) {
$this->_startOfView = 1 - $this->_startday;
} else {
if ($this->_startday == Horde_Date::DATE_SUNDAY) {
$this->_startOfView = -5;
} else {
$this->_startOfView = 2 - $this->_startday;
}
}
$startDate = new Horde_Date($this->year, $this->month, $this->_startOfView);
$this->_endDate = new Horde_Date($this->year, $this->month, Horde_Date_Utils::daysInMonth($this->month, $this->year) + 1);
$this->_endDate->mday += (7 - ($this->_endDate->format('w') - $prefs->getValue('week_start_monday'))) % 7;
if ($prefs->getValue('show_shared_side_by_side')) {
$allCalendars = Kronolith::listInternalCalendars();
$this->_currentCalendars = array();
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $id) {
$this->_currentCalendars[$id] = $allCalendars[$id];
}
} else {
$this->_currentCalendars = array('internal_0' => true);
}
try {
$this->_events = Kronolith::listEvents($startDate, $this->_endDate);
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$this->_events = array();
}
if (!is_array($this->_events)) {
$this->_events = array();
}
}
示例5: header
}
}
if (!isset($user) || !$auth->authenticate($user, array('password' => $pass))) {
header('WWW-Authenticate: Basic realm="' . $registry->get('name') . ' Feeds"');
_no_access(401, 'Unauthorized', sprintf(_("Login required for the requested feed (%s)."), htmlspecialchars($calendar)));
}
}
}
$feed_type = basename(Horde_Util::getFormData('type'));
if (empty($feed_type)) {
// If not specified, default to Atom.
$feed_type = 'atom';
}
$startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j')));
try {
$events = Kronolith::listEvents($startDate, new Horde_Date($startDate), array($calendar));
} catch (Exception $e) {
Horde::log($e, 'ERR');
$events = array();
}
if (isset($conf['urls']['pretty']) && $conf['urls']['pretty'] == 'rewrite') {
$self_url = Horde::url('feed/' . $calendar, true, -1);
} else {
$self_url = Horde::url('feed/index.php', true, -1)->add('c', $calendar);
}
$owner = $share->get('owner');
$identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($owner);
$history = $injector->getInstance('Horde_History');
$now = new Horde_Date(time());
$template = $injector->createInstance('Horde_Template');
$template->set('updated', $now->format(DATE_ATOM));
示例6: listEvents
/**
* Lists events for a given time period.
*
* @param integer $startstamp The start of the time period to
* retrieve.
* @param integer $endstamp The end of the time period to retrieve.
* @param array $calendars The calendars to view events from.
* Defaults to the user's default calendar.
* @param boolean $showRecurrence Return every instance of a recurring
* event? If false, will only return
* recurring events once inside the
* $startDate - $endDate range.
* @param boolean $alarmsOnly Filter results for events with alarms.
* Defaults to false.
* @param boolean $showRemote Return events from remote calendars and
* listTimeObject API as well?
*
* @param boolean $hideExceptions Hide events that represent exceptions to
* a recurring event (events with baseid
* set)?
* @param boolean $coverDates Add multi-day events to all dates?
*
* @return array A list of event hashes.
* @throws Kronolith_Exception
*/
public function listEvents($startstamp = null, $endstamp = null, $calendars = null, $showRecurrence = true, $alarmsOnly = false, $showRemote = true, $hideExceptions = false, $coverDates = true, $fetchTags = false)
{
if (!isset($calendars)) {
$calendars = array($GLOBALS['prefs']->getValue('default_share'));
} elseif (!is_array($calendars)) {
$calendars = array($calendars);
}
foreach ($calendars as &$calendar) {
$calendar = str_replace('internal_', '', $calendar);
if (!Kronolith::hasPermission($calendar, Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied();
}
}
return Kronolith::listEvents(new Horde_Date($startstamp), new Horde_Date($endstamp), $calendars, array('show_recurrence' => $showRecurrence, 'has_alarm' => $alarmsOnly, 'show_remote' => $showRemote, 'hide_exceptions' => $hideExceptions, 'cover_dates' => $coverDates, 'fetch_tags' => $fetchTags));
}
示例7: _content
/**
*/
protected function _content()
{
$GLOBALS['page_output']->addScriptFile('tooltips.js', 'horde');
$now = new Horde_Date($_SERVER['REQUEST_TIME']);
$today = date('j');
$startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j')));
$endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j') + $this->_params['days']));
try {
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
$calendars = Kronolith::listCalendars();
if (!isset($calendars[$this->_params['calendar']])) {
return _("Calendar not found");
}
if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) {
return _("Permission Denied");
}
list($type, $calendar) = explode('_', $this->_params['calendar'], 2);
$driver = Kronolith::getDriver($type, $calendar);
$all_events = Kronolith::sortEvents($driver->listEvents($startDate, $endDate, array('show_recurrence' => true)));
} else {
$all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
}
} catch (Exception $e) {
return '<em>' . $e->getMessage() . '</em>';
}
$html = '';
$iMax = $today + $this->_params['days'];
$firstday = true;
$totalevents = 0;
for ($i = $today; $i < $iMax; ++$i) {
$day = new Kronolith_Day(date('n'), $i);
$date_stamp = $day->dateString();
if (empty($all_events[$date_stamp])) {
continue;
}
$firstevent = true;
$tomorrow = $day->getTomorrow();
foreach ($all_events[$date_stamp] as $event) {
if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) {
break 2;
}
if ($event->start->compareDate($day) < 0) {
$event->start = $day;
}
if ($event->end->compareDate($tomorrow) >= 0) {
$event->end = $tomorrow;
}
if ($event->end->compareDateTime($now) < 0) {
continue;
}
if (!empty($this->_params['alarms']) && !$event->alarm) {
continue;
}
$event_active = $event->start->compareDateTime($now) < 0 && $event->end->compareDateTime($now) > 0;
if ($firstevent) {
$html .= '<tr><td colspan="3" class="control"><strong>';
if ($day->isToday()) {
$dayname = _("Today");
} elseif ($day->isTomorrow()) {
$dayname = _("Tomorrow");
} elseif ($day->diff() < 7) {
$dayname = $day->strftime('%A');
} else {
$dayname = $day->strftime($GLOBALS['prefs']->getValue('date_format'));
}
$url = Horde::url('day.php', true)->setRaw(false)->add('date', $day->dateString());
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
$url->add('display_cal', $this->_params['calendar']);
}
$html .= $url->link(array('title' => sprintf(_("Goto %s"), $dayname))) . $dayname . '</a></strong></td></tr>';
$firstevent = false;
$firstday = false;
}
$html .= '<tr class="linedRow"><td class="text nowrap" valign="top">';
if ($event_active) {
$html .= '<strong>';
}
if ($event->isAllDay()) {
$time = _("All day");
} else {
$time = $event->start->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia') . '-' . $event->end->format($GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:ia');
}
$html .= $time;
if ($event_active) {
$html .= '</strong>';
}
$html .= ' </td>';
$html .= '<td class="text" valign="top"' . $event->getCSSColors() . '>';
if ($event_active) {
$html .= '<strong>';
}
$html .= ' ' . $event->getLink(null, true, null, true, true);
if ($event_active) {
$html .= '</strong>';
}
$html .= '</td></tr>';
$totalevents++;
}
//.........这里部分代码省略.........
示例8: _content
/**
*/
protected function _content()
{
global $page_output;
$page_output->addScriptFile('tooltips.js', 'horde');
$now = new Horde_Date($_SERVER['REQUEST_TIME']);
$today = date('j');
$current_month = '';
$startDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n'), 'mday' => date('j')));
$endDate = new Horde_Date(array('year' => date('Y'), 'month' => date('n') + $this->_params['months'], 'mday' => date('j') - 1));
try {
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
$calendars = Kronolith::listCalendars();
if (!isset($calendars[$this->_params['calendar']])) {
return _("Calendar not found");
}
if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) {
return _("Permission Denied");
}
list($type, $calendar) = explode('_', $this->_params['calendar'], 2);
$driver = Kronolith::getDriver($type, $calendar);
$all_events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => true, 'has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false));
} else {
$all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS), array('has_alarm' => !empty($this->_params['alarms']), 'cover_dates' => false));
}
} catch (Exception $e) {
return '<em>' . $e->getMessage() . '</em>';
}
/* How many days do we need to check. */
$days = Date_Calc::dateDiff($startDate->mday, $startDate->month, $startDate->year, $endDate->mday, $endDate->month, $endDate->year);
/* Loop through the days. */
$totalevents = 0;
$html = '';
for ($i = 0; $i < $days; ++$i) {
$day = new Kronolith_Day($startDate->month, $today + $i);
$date_stamp = $day->dateString();
if (empty($all_events[$date_stamp])) {
continue;
}
if (!empty($this->_params['maxevents']) && $totalevents >= $this->_params['maxevents']) {
break;
}
/* Output month header. */
if ($current_month != $day->month) {
$html .= '<tr><td colspan="4" class="control"><strong>' . $day->strftime('%B') . '</strong></td></tr>';
}
$firstevent = true;
$tomorrow = $day->getTomorrow();
foreach ($all_events[$date_stamp] as $event) {
$isMultiDay = false;
if ($event->start->compareDate($day) < 0) {
$event->start = new Horde_Date($day);
}
if ($event->end->compareDate($tomorrow) >= 1) {
$isMultiDay = true;
}
if ($event->end->compareDate($now) < 0 && !$event->isAllDay() || !empty($this->_params['alarms']) && !$event->alarm) {
continue;
}
if ($firstevent || $isMultiDay) {
$html .= '<tr';
if ($current_month == $day->month) {
$html .= ' class="upcomingday"';
}
$html .= '><td class="text" valign="top" align="right"><strong>';
if ($day->isToday()) {
$html .= _("Today");
} elseif ($day->isTomorrow()) {
$html .= _("Tomorrow");
} else {
$html .= $day->mday;
}
if ($isMultiDay) {
$endDay = new Kronolith_Day($event->end->month, $event->end->mday);
$html .= ' - ';
if ($endDay->isTomorrow()) {
$html .= _("Tomorrow");
} else {
$html .= $event->end->mday;
}
}
$html .= '</strong> </td>';
$firstevent = $isMultiDay;
} else {
$html .= '<tr><td class="text"> </td>';
}
$html .= '<td class="text" nowrap="nowrap" valign="top">';
if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
$html .= '<strong>' . htmlspecialchars($event->getLocation()) . '</strong>';
} else {
$html .= htmlspecialchars($event->getLocation());
}
if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
$html .= '<strong>';
}
$html .= $event->getLink(null, true, null, true);
if ($event->start->compareDate($now) < 0 && $event->end->compareDate($now) > 0) {
$html .= '</strong>';
}
//.........这里部分代码省略.........
示例9: _content
/**
*/
protected function _content()
{
global $prefs;
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
$calendars = Kronolith::listCalendars();
if (!isset($calendars[$this->_params['calendar']])) {
return _("Calendar not found");
}
if (!$calendars[$this->_params['calendar']]->hasPermission(Horde_Perms::READ)) {
return _("Permission Denied");
}
}
$year = date('Y');
$month = date('m');
$startday = new Horde_Date(array('mday' => 1, 'month' => $month, 'year' => $year));
$startday = $startday->dayOfWeek();
if (!$prefs->getValue('week_start_monday')) {
$startOfView = 1 - $startday;
$endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($month, $year), 'month' => $month, 'year' => $year));
} else {
if ($startday == Horde_Date::DATE_SUNDAY) {
$startOfView = -5;
} else {
$startOfView = 2 - $startday;
}
}
$startDate = new Horde_Date($year, $month, $startOfView);
$endDate = new Horde_Date($year, $month, Horde_Date_Utils::daysInMonth($month, $year) + 1);
$endDate->mday += (7 - ($endDate->format('w') - $prefs->getValue('week_start_monday'))) % 7;
/* Table start. and current month indicator. */
$html = '<table cellspacing="1" class="monthgrid" width="100%"><tr>';
/* Set up the weekdays. */
$weekdays = array(_("Mo"), _("Tu"), _("We"), _("Th"), _("Fr"), _("Sa"));
if (!$prefs->getValue('week_start_monday')) {
array_unshift($weekdays, _("Su"));
} else {
$weekdays[] = _("Su");
}
foreach ($weekdays as $weekday) {
$html .= '<th class="item">' . $weekday . '</th>';
}
try {
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
list($type, $calendar) = explode('_', $this->_params['calendar'], 2);
$driver = Kronolith::getDriver($type, $calendar);
$all_events = $driver->listEvents($startDate, $endDate, array('show_recurrence' => true));
} else {
$all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
}
} catch (Exception $e) {
return '<em>' . $e->getMessage() . '</em>';
}
$weekday = 0;
$week = -1;
$weekStart = $prefs->getValue('week_start_monday');
for ($date_ob = new Kronolith_Day($month, $startOfView, $year); $date_ob->compareDate($endDate) < 0; $date_ob->mday++) {
if ($weekday == 7) {
$weekday = 0;
}
if ($weekday == 0) {
++$week;
$html .= '</tr><tr>';
}
if ($date_ob->isToday()) {
$td_class = 'kronolith-today';
} elseif ($date_ob->month != $month) {
$td_class = 'kronolith-othermonth';
} elseif ($date_ob->dayOfWeek() == 0 || $date_ob->dayOfWeek() == 6) {
$td_class = 'kronolith-weekend';
} else {
$td_class = '';
}
$html .= '<td align="center" class="' . $td_class . '">';
/* Set up the link to the day view. */
$url = Horde::url('day.php', true)->add('date', $date_ob->dateString());
if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
$url->add('display_cal', $this->_params['calendar']);
}
$date_stamp = $date_ob->dateString();
if (empty($all_events[$date_stamp])) {
/* No events, plain link to the day. */
$cell = Horde::linkTooltip($url, _("View Day")) . $date_ob->mday . '</a>';
} else {
/* There are events; create a cell with tooltip to
* list them. */
$day_events = '';
foreach ($all_events[$date_stamp] as $event) {
if ($event->isAllDay()) {
$day_events .= _("All day");
} else {
$day_events .= $event->start->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p') . '-' . $event->end->strftime($prefs->getValue('twentyFour') ? '%R' : '%I:%M%p');
}
$location = $event->getLocation();
$day_events .= ':' . ($location ? ' (' . htmlspecialchars($location) . ')' : '') . ' ' . $event->getTitle() . "\n";
}
$cell = Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . $date_ob->mday . '</a>';
}
/* Bold the cell if there are events. */
//.........这里部分代码省略.........
示例10: __construct
/**
*
* @global Horde_Prefs $prefs
* @param Horde_Date $date
*
* @return Kronolith_View_Month
*/
public function __construct(Horde_Date $date)
{
global $prefs;
$this->month = $date->month;
$this->year = $date->year;
// Need to calculate the start and length of the view.
$this->date = new Horde_Date($date);
$this->date->mday = 1;
$this->_startday = $this->date->dayOfWeek();
$this->_daysInView = Date_Calc::weeksInMonth($this->month, $this->year) * 7;
if (!$prefs->getValue('week_start_monday')) {
$this->_startOfView = 1 - $this->_startday;
// We may need to adjust the number of days in the view if
// we're starting weeks on Sunday.
if ($this->_startday == Horde_Date::DATE_SUNDAY) {
$this->_daysInView -= 7;
}
$endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($this->month, $this->year), 'month' => $this->month, 'year' => $this->year));
$endday = $endday->dayOfWeek();
if ($endday == Horde_Date::DATE_SUNDAY) {
$this->_daysInView += 7;
}
} else {
if ($this->_startday == Horde_Date::DATE_SUNDAY) {
$this->_startOfView = -5;
} else {
$this->_startOfView = 2 - $this->_startday;
}
}
$startDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView));
$endDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView + $this->_daysInView));
if ($prefs->getValue('show_shared_side_by_side')) {
$allCalendars = Kronolith::listInternalCalendars();
$this->_currentCalendars = array();
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $id) {
$this->_currentCalendars[$id] = $allCalendars[$id];
}
} else {
$this->_currentCalendars = array('internal_0' => true);
}
try {
$this->_events = Kronolith::listEvents($startDate, $endDate);
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$this->_events = array();
}
if (!is_array($this->_events)) {
$this->_events = array();
}
}