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