public function listTimeObjects(Horde_Date $start, Horde_Date $end, $category)
{
try {
$res = $this->getTimeObjectTurbaList($start, $end, $category);
} catch (Turba_Exception $e) {
/* Try the default implementation before returning an error */
$res = $this->_getTimeObjectTurbaListFallback($start, $end, $category);
}
$t_objects = array();
while ($ob = $res->next()) {
$t_object = $ob->getValue($category);
if (empty($t_object)) {
continue;
}
try {
$t_object = new Horde_Date($t_object);
} catch (Horde_Date_Exception $e) {
continue;
}
if ($t_object->compareDate($end) > 0) {
continue;
}
$t_object_end = new Horde_Date($t_object);
++$t_object_end->mday;
$key = $ob->getValue('__key');
// Calculate the age of the time object
if ($start->year == $end->year || $end->year == 9999) {
$age = $start->year - $t_object->year;
} elseif ($t_object->month <= $end->month) {
// t_object must be in later year
$age = $end->year - $t_object->year;
} else {
// t_object must be in earlier year
$age = $start->year - $t_object->year;
}
$title = sprintf(_("%d. %s of %s"), $age, $GLOBALS['attributes'][$category]['label'], $ob->getValue('name'));
$t_objects[] = array('id' => $key, 'title' => $title, 'start' => sprintf('%d-%02d-%02dT00:00:00', $t_object->year, $t_object->month, $t_object->mday), 'end' => sprintf('%d-%02d-%02dT00:00:00', $t_object_end->year, $t_object_end->month, $t_object_end->mday), 'recurrence' => array('type' => Horde_Date_Recurrence::RECUR_YEARLY_DATE, 'interval' => 1), 'params' => array('source' => $this->_name, 'key' => $key), 'link' => Horde::url('contact.php', true)->add(array('source' => $this->_name, 'key' => $key))->setRaw(true));
}
return $t_objects;
}